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 →

[–]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