Very often you start coding with bottom-up approach – first defining models, than implementing the service layer logic – with tests – then wrapping it up wih REST interface or user interface.
Setup Environment & Architecture
Before you could write any code – you need a structure. You must know where and how the application will run on, so you could set up similar settings on the development machine. If anything mismaches – from coding to production
- General Hardware Architecture,
- Cloud Provider,
- OS,
- Application Runtime (like Java/C#/etc),
- library versions
You may get the situation – “It works on My Machine“.
Applications in the past were developed from a single project/codebase/monolith – so you need to set up one building unit. Nowadays you develop your software units with a network of nodes (Micro Services) – that may be started and stopped according to load, geographically distributed, etc. This is the System Administration (or DevOps phase).
At some point you get to the development of the atomic development item where you:
- Create project
- with IDE wizard
- with CLI
- web page for app bootstrap
- Setup Code Structure and Organization
- Define Dependency Manager
- Set up building and packaging scripts
There are generally two ways I’ve seen – the code to be organized:
- By Feature
- Micro Services themselves could be seen as organizing in features.
- Different Screens of an app could be organized as features
In many cases there is a folder containing common items for all features.
- By Layer – and if the features are a lot – there could be sub-folders in each layer – organizing functionalities.
- A Standard Single Micro Service is generally organized in layers so it could be easily tested
Defining Data Models
In whatever platform – you first start by defining the information holders. This is why models are the main driver of several of my products:
- https://programtom.com/dev/product/json-model-extractor-quarkus-vaadin-web-app/ – App for Extracting Data Models From JSON
- App Builder / Code Generator – https://programtom.com/dev/product/app-builder-code-generation-spring-micro-service-vaadin-app/ – where you have the ability to define on a Web App – your models and generate Plain Old (Pick your Language) Objects. I’m focused on Java, Kotlin & Dart
- IntelliJ Plugin: https://github.com/tomavelev/app_builder_plugins – that allows you to generate new files from the models.
Data Access, Repository And Services
Repositories are just another name for data access classes. In Flutter they are also wrappers of different Data Access origins with bonus mappings.
Services on other hand should not be just for thin layer between the controllers and data access, but should contain the main business logic. It should not have any dependency
- On the User Interface / Platform
- Or on the Data Source of the information
REST and/or User Interface
Web Controller, REST endpoints and user interfaces generally should be very thin software layers. But, the User Interface has evolved to be complex and is now embracing the whole layering from all the above within itself. Such examples are Flutter Apps with BloC, Angular & React.