04:03 am - akktri - Searchable data field boxes? I find this particular item impossible to find.I'd like to know how to be able to create a box in html where you can type a phrase in a box on a web page and pull up the hidden data from that page according to the phrase.Also, I'd like to figure out how to do that with open data (it would probably be something like the "a href=#A" thing, I'm guessing)
03:20 pm - trajano - Introduce Adapter This is a refactoring I generally do, but I can't seem to find it in www.refactoring.com, it might be an anti-pattern for what I know, what do you think? Also the refactoring link at the note below does not exist yet from what I know since I have to write it still. objectB.setA(getA(objectA)); objectB.setB(getB(objectA)); | v ObjectAdapter adapter = new ObjectAdapter(objectA); objectB.setA(adapter.getA()); objectB.setB(adapter.getB()); MotivationObjects that are as simple as Strings or as complex as HttpServletRequest have data that we need to retrieve. However, we need to get specific pieces of data either by using the String.substring() or HttpServletRequest.getAttribute() methods. The direct approach forces an understanding on the how the data is stored in the objects. The Adapter design pattern is used to wrap an existing object with another object that provides methods that would be named closer to what the client would need and limits the possible inputs to the actual object to what clients would normally need so developers do not have to know which part to get from the data. ( Read more...Collapse )
03:55 pm - trajano - Move getter logic to constructor public String getId() { return data.substring(0,4); } | v private final String id; public DataAdapter(String data) { this.id = initId(); } public String getId() { return id; } MotivationSometimes when one part of an object is accessed, it has to access everything. And sometimes the value does not change after it is calculated once.Also construction of an object is generally synchronized, most languages do not allow any methods from accessing a new object while it is being constructed.( Read more...Collapse )