As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Hi
I have an assignment to teach a team the subject of design principle. As a final exercise to this mini course, I thought to give them an exercise in design pattern, in Java.
My idea is to give them a code written badly, and they should refactor it using several design patterns. I didn't find anything similar to that in my search (both in the web and in stack overflow).
Any references to something similar to what I'm looking for?
Thanks
One of the best sites out there : http://www.industriallogic.com/xp/refactoring/catalog.html
They basically show you code, and then the re-factored code. Its not going to be one big hopping pile of crap, but you can take an aggregate a couple and aggregate them together to form some ugly code, and then do the same to show the solution.
You can check this book "Refactoring: Improving the Design of Existing Code" of Martin Fowler. It contains examples of "smell" coding and provide solution to refactor it.
This has alot of code filling the bill. The author, Joshua Kerievsky, is also the founder of Industrial Logic, which has (as Nix noted in his response) good material on this topic, drawn from and augmenting this book.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have been programing for about a year now, and have a very good grasp on all the basic of programming in generaly and am a pretty decent Java programmer, so now that I have the time I would like to start making games in Java. However, Id really like to not use any extra librarries, and just use pure Java for the first little bit until I fully understand the machanics of a video game.
I have been looking around the internet and have seen more "best ways" to do this than I can count. So if somebody could point me in the right direction that would be great! (As in send me to the best, easiest to follow, and most up to date ressource either print or on the web)
It just seems that no matter where I look I get completly diffrent info on the same subjuct. So I would really apreciate if somebody could just give me a resource that follows whatever the current standard is.
P.s typed on my phone so sorry for any typos :-)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am experiencing the pain of developing an API based on (Selenium2) Webdriver and here is my dilemma.
I have basically 4 packages:
com.example.qa.pageobject
com.exmaple.qa.setup
com.example.qa.test
com.example.qa.utils
In com.example.qa.test, i have test classes that "USE" classes from other packages.
I am ending up in the following test method.
#Test
public void testScenario16786() {
Login login = new Login();
login.setUp();
AddSingleDomain asd = new AddSingleDomain();
asd.addSingleDomain();
AddARecord ar = new AddARecord();
ar.AddARecordTest();
}
Now, this seems to be a very bad example of developing in Java, which almost seems procedural. Is there any other way of doing it ? Are there some RULES that i need to be aware of while designing an API, which will be used by others ? i am sure that this is somewhat of a classical problem and has been solved before, i just want to know what are the many ways of resolving this, like:
One resolution, could be to use Factory Pattern, and based on a key, a specific class is instantiated, which is good but is there a more elegant way ?
Your test class is necessarily procedural - a repeatable set of steps, that's fine.
The commonly recommended approach is to use the Page Object pattern and selenium also provides a PageFactory object to help you (see end of the page):
page objects
You might find the presentation "How to Design a Good API & Why it Matters" by Joshua Bloch to be helpful.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
The community reviewed whether to reopen this question 11 months ago and left it closed:
Original close reason(s) were not resolved
I am a Java developer, and I'm interested in improving the quality of my Javadoc comments in the code and programs I write to make it more comprehensible and easier for other developers to implement.
I've read lots of articles, including those from official sources, and I try to follow the guidelines stated in the book
"The Elements of Java Style", but despite this, and after searching extensively online, I can't seem to find a practical way to compare my existing Javadoc(s) to model examples and maintain best practices for Java API documentation.
Peer review.
Try and find someone outside your team (a customer) and ask them what they think about your JavaDoc.
The customer is always right.
Also i can share you some stuff below
A great read on writing javadoc is at the sun site at http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
The best thing I've learned from that text is probably that your class level javadoc should start with "Provides". This forces you to think about what that class provides to your program (or the world). It's not uncommon for me to redesign software because writing javadoc made me think "hey, this is not needed here!".
Other practical tips: When a getter is interesting, try to write it in the #returns tag. Not doing so might mean that you type stuff twice, once in the javadoc, and once after the #return tag.
An the best tip: If you don't know what to write, DONT. the Javadoc parser does a great job of automatically generating getter javadoc for example, but it only does it when you didn't add a /** */.
Javadoc should desccribe WHAT your method does, not HOW.
Javadoc is not your todolist. I've tried it, but for larger projects, it simply doesn't work.
In addition to the Sun's (now Oracle) documentation at http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html I would recommend the "Item 44: Write doc сomments for all exposed API elements" from the "Effective Java" book by Joshua Bloch, 2nd ed. pp.203-208. This is a 6 page recommendation/tips with several practical examples.
You can use #link parameter for 'VoucherStore'
Example:
#return {#link VoucherStore} type Concrete Object based on storeType parameter
instead of
#return returns VoucherStore type Concrete Object based on storeType parameter.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I know that is Collections.sort() method in Java but I think quicksort is worth to remember and try.
My work target is general Java: web, database access, integration, not game developer, scientific application or another one that depends on advanced algorithms.
Which algorithms should I learn to pass without stress Java developer interview?
Fizz Buzz
I usually don't care, if a developer knows the basic algorithms by heart. I do care, if he is capabale of understanding requirements and translating them in correct, testable and understandable pieces of code.
Ah, and I do care if he knows how to implement the most common design patterns. And he should know when and how to use collections, threads and - String#split - it's amazing how many "developers" don't know how to read and process a simple csv file.
Although I fully agree with Joachim comment, I would go for : collection selection. This is not an algorithm per se, but rather a good view of which collection is good for which purpose :
sorted content with constant lookup time ? TreeSet !
mapped data with memorization of insertion order ? LinkedHashMap !
using that, and some knowledge of design patterns behind collections, you will far too often reply to algorithms questions using the knuth answer (or the subtle variation : as long as Sun developpers implemented it correctly, I only have to choose wisely).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I have about four years of experience as a Java developer. I'm planning to get myself involved in the world of UML. Can anyone suggest some good books and reference material for UML?
UML Distilled, by Martin Fowler.
I have it here, and it's a very good introduction. Actually, it was a "required reading material" for my university, so can be thought of as a textbook as well.
Book Applying UML And Patterns
http://www.craiglarman.com/wiki/index.php?title=Book_Applying_UML_and_Patterns
I used it during my study
I would recommend The Unified Modeling Language User Guide, written by the creators of UML, the "Three Amigos" of software engineering (Grady Booch, Ivar Jacobson and James Rumbaugh).
Check out the UML Resource Page of the OMG. Among other resources, this page has links to the latest UML specifications.
There are plenty of good books available as well:
The Unified Modeling Language Reference Manual - Rumbaugh, Jacobson, and Booch
The Unified Modeling Language User Guide - Booch, Rumbaugh, and Jacobson
UML Distilled - Martin Fowler
I am currently reading:
Object-oriented Systems analysis and design using UML
By Simon Bennett
It is given as indicative reading on my degree course, and has genuinely helped me a lot.
Don't read any book because all these guys just talk about UML but not about real life.
I would recommend to manually code and then reverse your code into a class diagram. You can also reverse a sequence diagram from your methods.
Don't do more and certainy not read books because it is a waste of time :-)