Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI First or logic first?

While working on projects, I often come to the dilemma of working on UI first or on logic first. Having UI first gives a nice overview of how the end product is going to look like whilehaving logic first uncovers any possible roadblocks in technology.

However, it is not always that crystal clear.. some times UI may need data to be populated to really show what it means and simulating the data could be more difficult than inplementing the logic.. what is your preferred approach for development and why? Which is more efficient and effective? ( I am seeing this issue more and more with iphone projects)

like image 343
Kiran Avatar asked Oct 10 '22 17:10

Kiran


2 Answers

Neither.

You will have to so some thinking at the beginning of the project anyway, deciding the general approach you will take and what operations you will support.

Do that reasonably well and you will have defined the interface between the view and the underlying logic. Look at the Model-View-Controller approach for some inspiration.

What you want to have early on is an idea of what are the basic operations your logic code needs to do to in order to achieve a purpose. Usually it will be a simple function call but sometimes it may involve more than that. Have that clear first.

Next, a complex system that works is based on a simple system that works.

Which means you will need to have a basic UI you'll use to test a basic logic implementation first. A simple form with a button which presents a message is basic enough. Then, it can grow, you implement a piece of functionality and then you add a simple UI you can test it with.

It is easier to do both piece by piece as the logic and UI for a small piece of the logic are conceptually similar and it will be easy to keep track of both while you implement and test.

The most important part is to keep the UI and logic decoupled, making them talk through a common interface. This will allow you to make quick edits when needed and improve the looks of the GUI towards the end.

You will be better able to just scrap the UI if you don't like it. All you'll need to do is use the same interface, one which you know how to do because you wrote it and you already implemented it.

If at some point you realize you've made a big mistake you can still salvage parts of the code, again because the UI and logic are decoupled and, hopefully, the logic part is also modular enough.

In short: think first, do both the UI and the logic in small increments and keep things modular.

like image 101
Andrei Avatar answered Oct 23 '22 20:10

Andrei


Iterate between both (logic and UI). Back and forth. The UI may change as you understand how and what you can do with the logic and whatever constraints that may present. The logic may change as you change the features, behavior, or performance requirements of an easy-to-use, responsive, and decent looking UI.

I usually do the minimum possible of each until I have some barely working mockups. Then I use each mockup to test where my assumptions about the proper UI and/or logic might be right or wrong. Pick the most flawed, and start iterating.

Apple suggests mocking up the UI on paper first. (Have an eraser handy...)

like image 24
hotpaw2 Avatar answered Oct 23 '22 18:10

hotpaw2