comment, the name does not reveal its intent int d; What does it mean? Days? Diameter? int d; / /elapsed time in days Is this any better? Monday, 11 March, 13
comment, the name does not reveal its intent int d; What does it mean? Days? Diameter? int elapsedTimeInDays; What about this? int d; / /elapsed time in days Is this any better? Monday, 11 March, 13
private Date modymdhms; private final String pszqint = “102”; } class Customer { private Date generationTimestamp; private Date modificationTimestamp; private final String recordId = “102”; } Monday, 11 March, 13
= new CreditCard(“1234567890121234”); cc.charge(100); } CreditCard API lies It pretends to not need the CreditCardProcessor The API doesn’t tell the exact order of the initialization Monday, 11 March, 13
new OfflineQueue(database); creditCardProcessor = new CreditCardProcessor(queue); CreditCard cc; cc = new CreditCard(“1234567890121234”, creditCardProcessor); cc.charge(100); } Dependency injection enforces the order of initialization at compile time. Monday, 11 March, 13
dd, yyyy Pattern timePattern = Pattern.compile( “\\d*:\\d*:\\d* \\w*, \\w* \\d*, \\d*”); Todo Comments /* TODO: All calls to getPage should actually come here, and be relative to the current page, not the parent page. It was a gross error to have the whole wiki know that references were relative to the parent instead of the page. */ Pubic API documentation Monday, 11 March, 13
this component. */ protected int backgroundProcessorDelay = -1; /** * The container event listeners for this Container. */ protected ArrayList listeners = new ArrayList(); Monday, 11 March, 13
The bug was that the Now Playing screen was somehow being launched, in that viewDidAppear was being called, but the view was not being shown on the screen. The Now Playing screen then when on to do all it's stuff and the user was left looking at an incomplete Mode screen. So the "fix" is to kill off any residual Now Playing screen that is under the Mode tab whenever we start a new connection to a radio. */ What is FS-13005? Sorry! I have no idea what you are talking about. Monday, 11 March, 13
but not both public boolean set(String attribute, String value); if (attributeExists(“username”)) { setAttribute(“username”, “Ben”); } Monday, 11 March, 13
public Point topLeft; public double side; public double area() { return side*side; } } public class Rectangle implements Shape{ public Point topLeft; public double height; public double width; public double area() { return height * width; } } Monday, 11 March, 13
Pros: easy to add new functions without changing existing data structure Cons: hard to add new data structure all the functions must change OO code Pros: easy to add new classes without changing existing function Cons: hard to a new function as all classes must change Monday, 11 March, 13
Pros: easy to add new functions without changing existing data structure Cons: hard to add new data structure all the functions must change OO code Pros: easy to add new classes without changing existing function Cons: hard to a new function as all classes must change Avoid Hybrids Monday, 11 March, 13
(Employee e : employees) { totalPay += e.getPay(); } public List<Employee> getEmployees() { if (/* there are no employees */) { return Collections.emptyList(); } } Monday, 11 March, 13
1. upload a video 2. store in s3 3. start worker and send request to worker 4. dedicated worker pulls the file from s3 and do transcoding Monday, 11 March, 13
before coding, don’t create messy stuffs by your first impression do testing before adopting to the real code read the API, doc and Google ask others ... Monday, 11 March, 13
alert count down from 5 to 0. Explain why it doesn’t work and fix the bug. function count (num) { for (var i = 0; i <= num; i += 1) { setTimeout(function () { alert(num - i); }, i * 1000); } } count(5); Monday, 11 March, 13