code review based on what I learned from D
Szabo Bogdan via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 4 23:53:34 PDT 2015
Hi,
Recently while I was reviewing some swift code, a colleague left
me the impression that I am the one with the bad habits and these
were learned while coding in D. I still think that I proposed
some changes to avoid some bugs but I was told that I am focusing
on defensive programming and that is a bad thing.
The first issue that I raised was this one:
func renderCell(item: AnyObject, index: Int) {
- fatalError("renderCell has not been implemented")
+
}
where I proposed to make that method abstract or let's not remove
the fatalError message because this method it should be never
called.
The second issue was this:
+ init(dataSource: WUPTableDataSource) {
+
+ self.dataSource = dataSource
+ dataSource.tableView = tableView
where I asked what happens if someone passes a dataSource that
has a tableView set. I this class, there were set some events
bind to the view and it was unclear what happened in that case
and I proposed to add an assert to check if dataSource.tableView
is not set before we set it.
For both of these issues I was told that swift is not Java and if
the situations that I described happens, you don't want to crash
the user app, because this will make the user unhappy.
Those things are for me, good habits that I do when I am
programming with D. What do you think? and if I had bad ideas
with those issues, what I can do to improve my skills?
thanks,
Bogdan
More information about the Digitalmars-d-learn
mailing list