Abstraction: What is it and how can it speed up your Flutter development?

abstraction

Abstraction, according to the dictionary, is the process of taking away or removing characteristics from something. Likewise, in the IT world, Abstraction is a crucial concept that every developer must know. To fully understand what it is and how it helps in Flutter, today ArrowHiTech experts would like to deliver a dedicated article. Hope that you’ll read till the end.

And now, without further ado, let’s get started with

What is Abstraction?

We use Abstraction to describe things in simple languages and terms. In short, it’s used to create a limit, a boundary between client programs and the app. Abstraction‘s goal is to handle the complexity by removing or hiding excessive details from users. As a result, it will create a better user experience!

There are 2 types of abstraction:

  • Data: is the object data that is hidden from the outer world, or not publicly displayed
  • Process: is the functions that is hidden, which involve in a user operation
abstraction type

BUT, the question is, do you really need Abstraction? Let’s find the answer!

Why is Abstraction important?

Besides the main advantage of simplifying the process, Abstraction also offers many other key benefits:

#1. Easy maintenance

… especially long-term. Instead of implementation, business logic is written against interfaces. As a result, Abstraction allows you to change implementations many times, yet, feel safe about system-wide refactors.

#2. Simple understanding

This Abstraction feature is really helpful regarding Declarative programming. We can approach telling compilers the action and just leave the implementation details out. Thanks to Abstraction, newcomers or starters in developing can consume easily because we only need to focus on business logic.

#3. Quick testing

abstraction mobile app

Testing is really important in each part of every process. Likewise,  running  unit tests will detect and confirm what’s going on. Moreover, abstraction also lets you provide mock or fake data versions to write more robust tests. In the end, it leads to  a much wider range of functions.

#4. Immediate implementations

In terms of swapping out implementations, abstraction surely boosts the overall development process. For example, bug fixing, testing and so on. Consequently, The GMO products version will be released much faster. Thus,You will know what to fix for the official version and customers will be much easier to satisfy. Let’s take an  API as an example.  abstraction allows you to implement what will return according to what you require. So,  the implementation returns a user with 1000 posts, 50 comments and errors when they like a post.

#5. Fast development ( via simple architect )

  • Firstly, your team should define the architecture, necessary services, methods and properties which are vital.
  • Next, the lead architecture should define interfaces then set up basic interactions.
  • Then, hand out interfaces and give the rules on ways to process errors.
  • Write the unit tests for every service when you’re ready.
  • Lastly, use fake implementations which will return the estimated outcome to test the whole process.

#6. Fake data

Development doesn’t take days or months with fake data. Instead, a few hours of service setup (to return data) is enough to start developing! Furthermore, many have used this method to build robust demos. Hence, if they need to implement, they would not have to throw real code away. 

Another point is that this method can be done before API is completed. Abstraction does indeed wonders for mobile app development, especially in bug fixing!

Now that you know why abstraction is essential to know, the final question is “How to make it fast?” There’s only 1 answer: Fake Data. Thus, we will illustrate a method to speed up abstraction using fake data.

How to make Abstraction faster for Flutter?

  1. Get the user profile with many posts, comments, shares, … That’s the core flow
  2. Move on to the new profile with fewer posts, comments, … moreover, you can leave some area blank
  3. Flesh out the whole app (without depending on API)
  4. There you go, you will now get a user profile, which throws an exception if it makes a call. 

As a result, this method of making abstraction faster will let you handle every error and mistake in your app. To clarify, we got 2 examples here:

class FakeApi implements Api {
  @override
  Future<List<Comment>> getCommentsForPost(int postId) async {
    await Future.delayed(Duration(seconds: 1));

    if (postId == 1) {
      return List<Comment>.generate(10, (index) => Comment());
    }

    return null;
  }

  @override
  Future<List<Post>> getPostsForUser(int userId) async {
    await Future.delayed(Duration(seconds: 1));

    if (userId == 1) {
      return List<Post>.generate(10, (index) => Post());
    }

    if (userId == 2) {
      return List<Post>();
    }

    return null;
  }

  @override
  Future<User> getUser(int userId) async {
    await Future.delayed(Duration(seconds: 1));

    if (userId == 1) {
      return User(name: 'dane', phoneNumber: '123-456-00');
    }

    if (userId == 2) {
      return User(name: 'Flutter', phoneNumber: '987-654-33');
    }

    return null;
  }

  @override
  Future<LoginResponse> login({String username, String password}) async {
    await Future.delayed(Duration(seconds: 1));

    if (username == 'dane') {
      return LoginResponse(userId: 1);
    }

    if (username == 'flutter') {
      return LoginResponse(userId: 2);
    }

    return LoginResponse(success: false, message: 'Username not found');
  }
}

If you want to learn more about Flutter in general, feel free to read these articles:

Having trouble? Contact experts – AHT is ready to serve!

With ultimate strength and uniqueness, we would love to work with you!

  • Rich Experience: ArrowHiTech was founded in 2007. Today, we are one of the leading IT outsourcing companies in Vietnam. Throughout 13 years, we have met the demands of more than 1,000 customers and completed more than 10,000 projects worldwide. Language border is non-existent when working with us!
  • Low Cost: Located in Vietnam, hence, our labour fee is extremely affordable. We always provide a wide range of selection with different prices so that any customers can choose their favorite and suitable ones.
arrowhitech
We are the leading IT outsourcing company from Vietnam!
  • High Quality: Although ArrowHiTech provides fair prices, our products are always high quality. You can check out our portfolios, as well as others’ ratings and reviews right
  • Strong Dedication: We believe that dedication and passion is the core value which results in the optimal working experience. Our team always prioritizes customers’ needs and demands. ArrowHiTech believes that this is our strength and our must-have value to our responsibility towards every single client. 

For those reasons, you can fully trust us on any State Management issues! You can see our Flutter App Development Services to see some further works of ours.

Bottom line

That is the end for this topic! Overall, we have explained what is Abstraction and how to make it fast for Flutter. We hope that you have gained more insight into this issue! If you need help, ArrowHiTech is just one call away. As always, we wish the best of luck to you and your future successful business! 

Tags

Share