What is Beautiful Code?
Angelo Saber
Senior iOS Developer (Swift | SwiftUI) at Fire Force in Kuwait | Master's in Software Engineering | Bridging the Gap Between App Development and AI Integration | Passionate about Machine Learning
What is Beautiful Code?
How to Write Beautiful Code ?
var cellEstimateHight = 152
Method name must be verb (meaning what this function is do ) like if you are calculate any process , that is should reflect to the Method Name . for example :
func calculateRectangle(sideA : Double, sideB: Double) -> Double{ }
领英推荐
2- Organization of your workspace :?
?? You have to orange your project depend on functionally , create groups of files that relate to each other.?like all view model in one group , all helpers in one group .
3- Local Values and Global Values : Firstly you have clear perspective what is global and what is local variable for the current scope.
4- Constants : Constants are pieces of information that don’t have much value so you shouldn’t pay attention to it. you should do is to create a file with constants, create a coding standard for naming constants, group them using marks, and then use them in the classes. One more benefit of constants is that you can reuse them .?
5- Class size : a class shouldn’t be longer than 300 lines, without comments, but there will be exceptions, of course. Small classes are much easier to understand, manage, and change.Readability should always be the priority relative to class size. Your functions should also be small, easy to read and understand. You should have a maximum number of lines for function, and if the function has more lines than allowed, you should refactor it.?
6- Design patterns : Each pattern is like a blueprint that you can customize to solve a particular problem in your code, and after a little bit of practice, quite easy to understand and implement. Design patterns make communication between developers more efficient. Software professionals can immediately picture the high-level design in their heads when they refer to the name of the pattern used to solve a particular issue.
7- Code review : While the primary purpose of code reviews should be functionality, we also need to take care about readability and organization of the code. Some tools can help you with code reviews like SwiftLint or Tailor.