Skip to content

This repository contains examples of clean and dirty code in Swift and Ionic, along with explanations and best practices for writing clean code. Both examples will include Casey Muratori's example of a clean code, translated from C++ in both Swift and Ionic.

Notifications You must be signed in to change notification settings

albu-alex/CleanVsDirtyCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Clean vs Dirty Code 🧠 🚀

This repository contains examples of clean and dirty code in Swift and Ionic, along with explanations and best practices for writing clean code. Both examples will include Casey Muratori's example of a clean code, translated from C++ in both Swift and Ionic.

Swift

Clean Code

The Swift examples of clean code demonstrate the following best practices:

  • Clear and concise naming conventions for variables, functions, and classes
  • Proper use of access modifiers to control the visibility of data and functionality
  • Proper error handling using try, catch, and throw
  • Consistent formatting and indentation

Dirty Code

The Swift examples of dirty code demonstrate the following anti-patterns:

  • Poor naming conventions that make the code difficult to understand
  • Overuse of global variables and functions
  • Lack of error handling, resulting in potential crashes and other issues
  • Inconsistent formatting and indentation

Benchmark results:

iOS Benchmark

Ionic

Clean Code

The Ionic examples of clean code demonstrate the following best practices:

  • Clear and concise naming conventions for variables, functions, and classes
  • Proper use of the Ionic component library to build user interfaces
  • Consistent formatting and indentation

Dirty Code

The Ionic examples of dirty code demonstrate the following anti-patterns:

  • Poor naming conventions that make the code difficult to understand
  • Overuse of custom CSS instead of utilizing the Ionic component library
  • Lack of consistency in formatting and indentation

Benchmark results:

Ionic Benchmark

Conclusion

By examining these examples of clean and dirty code, the results were a lot more clear for the Swift implementation, with the clean code implmementation being consistently better. Regarding Ionic, the same cannot be said. A quick analysis of the implementation showed me that the clean code is mostly faster than dirty code, but this is not a rule.

About

This repository contains examples of clean and dirty code in Swift and Ionic, along with explanations and best practices for writing clean code. Both examples will include Casey Muratori's example of a clean code, translated from C++ in both Swift and Ionic.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published