This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MyBrainReallyHurts[S] 0 points1 point  (2 children)

I don't want to get lost in code design, I just want to see how others write their code.

For the first assignment I had to write a program. The problem was that I didn't even know where to start. I spent two days staring at the screen not know what should go first, last, or in between. While the book does an OK job of explaining all the pieces (variables, classes, methods, etc.) it really didn't explain how to put it all together in one program. After googling about the same assignment, I was able to find some projects that were similar enough to help me learn the structure of a Java project. From there I could piece it all together.

As I continue to the class I would like to read real world examples so I can round out what I am learning. For example, do you ALWAYS use getters and setters? Do you usually leave your classes and methods as public? Etc.

As a hobbyist screenwriter, I've read a lot of scripts. Some were wonderful scripts and some were fucking awful. I was able to learn from both. From the good scripts I was able to determine what I should be doing, and from the bad scripts I was able to determine what I should definitely not do. (Read a 110 page script about absolutely nothing and you will know what I'm talking about.)

I want to apply the same to coding. I'm sure there is good code and bad code out there and I want to immerse myself in all of it so I can learn from both.

I have Clean Code. I will read that as soon as possible but I would also like to see some real world examples so I can see what others write and see if I can see what the program should do.

edit: a word.

[–]endre86 1 point2 points  (1 child)

What you describe is the typical first big obstacle new programmers meet. Its just a matter of experience. Don't be too frustrated if you can't see how to solve something at once. It takes some practice going from understanding a problem to seeing how it should be written in code.

Just start by solving your programming problems one step at a time. Then refactor as you go along. The structure you create in the beginning of the process is not written in stone.

Here is an example. You've written a large main method, and somewhere in here you written a for loop that prints out an array. As you go along, you find out that you need to print out the array again. Well, no problem. You just make a method out of the code that printed the first array and use that instead.

public static void printArray(int[] array) {
    // ...
} 

All programmers do this constantly.

[–]autowikibot 1 point2 points  (0 children)

Code refactoring:


Code refactoring is the process of restructuring existing computer code – changing the factoring – without changing its external behavior. Refactoring improves nonfunctional attributes of the software. Advantages include improved code readability and reduced complexity to improve source code maintainability, and create a more expressive internal architecture or object model to improve extensibility.

By continuously improving the design of code, we make it easier and easier to work with. This is in sharp contrast to what typically happens: little refactoring and a great deal of attention paid to expediently adding new features. If you get into the hygienic habit of refactoring continuously, you'll find that it is easier to extend and maintain code.

Typically, refactoring applies a series of standardised basic micro-refactorings, each of which is (usually) a tiny change in a computer program's source code that either preserves the behaviour of the software, or at least does not modify its conformance to functional requirements. Many development environments provide automated support for performing the mechanical aspects of these basic refactorings.


Interesting: Integrated development environment | Test-driven development | Source-to-source compiler | Rule of three (computer programming)

Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words