Best practice for application development and design pattern's

Best practice for application development and design pattern's

Why do we need architecture and design patterns?

An application architecture describes the patterns and techniques used to design and build an application. The architecture gives you a roadmap and best practices to follow when building an application so that you end up with a well-structured app. And design patterns help to make the purpose more simple and easy to work with.

Clean Architecture

Clean architecture is a method of software development in which you should be able to identify what a program performs merely by looking at its source code. The programming language, hardware, and software libraries needed to achieve the program’s goal should be rendered obsolete. Like other software design philosophies, Clean architecture aims to provide a cost-effective process for developing quality code that performs better, is easier to alter, and has fewer dependencies.?Robert C. Martin?established clean architecture and promoted it on his blog, Uncle Bob, in 2011.

  1. The most abstract circle is in the center, while the most concrete ring is on the outside. The Abstraction Principle is what this is referred to as. According to the Abstraction Principle, inner circles should include business logic, whereas outer rings should contain implementation details.
  2. The Dependency Rule is another Clean Architecture principle. This rule states that each circle can only rely on the inner circle closest to it, allowing the architecture to function.

Point to Remember:

  • Only the outer layers may rely on the inner layers for communication.
  • The amount of layers is entirely up to you: Make it fit your requirements.
  • In intimate circles, things grow more abstract.


Advantages of Clean Architecture

  • Code is easy to test than with standard MVVM.
  • Perfectly curated separation (the most considerable advantage).
  • User-friendly package structure.
  • Easy to keep the project running.
  • Your team will be able to implement new features even faster.

Disadvantages of Clean Architecture

  • The learning curve is a little steep. It may take some time to learn how all levels interact, especially if you’re coming from architectures like simple MVVM or MVP.
  • It contains many extra classes, so it’s not suitable for applications with a low level of sophistication.

MVVM Architecture

MVVM Is a presentation layer architecture for any application and it can be used with Clean Architecture

  • The model defines the Data Related Logic (DRL), which some application operates with. It directly controls the data & fundamental behaviors, separate from the User Interface (UI).
  • The view provides output representation of information, i.e. UI.
  • The controller generates an interface to connect two previous components. It operates straight to its user by receiving input data & performing appropriate operations with the model layer and view layer.

Layers of MVVM?

There are differing viewpoints on the number of levels that Clean Architecture should have. The design does not specify separate layers but instead lays the groundwork. The concept is that you adjust the number of layers according to your need. Here, to keep it short, we will use five, have a look at them.

  • Presentation:?This is a layer that interacts with the (UI)user interface.
  • Domain:?The app’s business logic is stored here.
  • Use cases:?Interactors are another name for them.
  • Data:?All data sources are defined in a broad sense.
  • Framework:?Implements interface with the Android SDK as well as concrete data layer implementations.

Design patterns

The term design pattern in application development basically means that there are reusable patterns to solve commonly occurring development problems.?The?android design pattern?is no different. There are specific design patterns which the developer must follow while writing the code for an application in Android.

The main three categories of?Android design patterns?explained in the simplest terms are: –

  • Creational Pattern – This Pattern is used to create an object without actually showing the logic or even the steps involved behind the creation of this object.
  • Structural pattern – The main concern of the Structural pattern is a clear idea regarding the structure of the code.
  • Behavioral Pattern – This pattern in a way acts as a mediator between understanding the pattern of the object and maintaining the structure of the code.??

Builder Design Pattern

When to Use Builder Pattern?

  • When the process involved in creating an object is extremely complex, with lots of mandatory and optional parameters?
  • When an increase in the number of constructor parameters leads to a large list of constructors?
  • When client expects different representations for the object that's constructed

Adapter Design Pattern

Adapter pattern works as a bridge between two incompatible interfaces. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces.

This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop

Observer Design Pattern

Observer pattern is used when there is one-to-many relationship between objects such as if one object is modified, its dependent objects are to be notified automatically. Observer pattern falls under behavioral pattern category.

What’s next?

  1. Use decoupled codebase
  2. Try to use dependency injection
  3. Make sure your codebase follow SOLID Principles
  4. Explore more design patterns
  5. Do comment in your code
  6. Follow OOP as much as you can
  7. Practice these with ROOMDb and RealmDB in your codebase
  8. Do use Unit testing and keep your code testable??

Rakib Khan

Software Developer At Akij Venture Group || Next Js || React Js || Typescript || Express Js || Mongodb || Nest || MySql || Docker || Jenkins

2 年

great article

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了