5 Misused Comments by developers that you should avoid at all cost!

[1] Noise Comments

// creating a customer object
let customer = Customer()

[2] Redundant Comments

// save the customer, before saving it makes sure that the 
// customer does not already exist
func saveCustomer(customer: Customer) -> Bool {
var isSaved = false
if !customer.exists() {
isSaved = customer.save()
}
return isSaved
}

[3] Position Markers

class Customer {	// properties //////////
var firstName: String
var lastName: String
// initializer //////////
init(firstName: String, lastName: String) {
self.firstName = firstName
self.lastName = lastName
}
// functions //////////
func save() {}
func update() {}
func delete() {}
}
  • In Declarative Framework like Flutter and SwiftUI, because of so many nested views, writing position marker is not considered bad.

[4] Closing Brace Comments

class Customer {	var firstName: String 
var lastName: String
init(firstName: String, lastName: String) {
self.firstName = firstName
self.lastName = lastName
} // end of initializer
func save() {

} // end of save function

func update() {

} // end of update function
func delete() {

} // end of delete function
}

[5] Commented-Out Code

class Customer {	var firstName: String 
var lastName: String
init(firstName: String, lastName: String) {
self.firstName = firstName
self.lastName = lastName
} // end of initializer
/*
func save() {

}

func update() {

}
func delete() {

}
*/

}

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
KD Knowledge Diet

KD Knowledge Diet

Software Engineer, Mobile Developer living in Seoul. I hate people using difficult words. Why not using simple words? Keep It Simple Stupid!