Project mistakes

This commit is contained in:
Oliver Kennedy 2017-03-03 17:29:41 -05:00
parent 449b15902f
commit a900a18287

View file

@ -0,0 +1,10 @@
---
title: CSE-562; Common Project Mistakes
---
### Use Strings instead of Enums in inner loops
`myString.equals("test")` is slooooooow. If the number of times that you need to call this function scales with the number of tuples in the data, consider using an [Enum type](http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html) instead.
### Non-compositional code
Maintaining separation of concerns is important. You *can* create one big main function that evaluates the entire query, but by checkpoint 2 it's going to become a mess of spaghetti code and a nightmare to maintain and debug. Break it up into smaller components. As mentioned in class, if you could have all of the logic encapsulated in a function, that would be the best possible option. However, since that requires `O(N)` memory, instead you should encapsulate the logical elements in iterators: Create a "Filtering" iterator, a "Mapping" iterator, an "Aggregating" iterator, etc...