1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome to Lake Valor!
    Catch, train, and evolve Pokémon while you explore our community. Make friends, and grow your collection.

    Login or Sign Up

Good Architecture vs. 'Good' Code

Discussion in 'The Lounge' started by Reckless, May 26, 2015.

Thread Status:
Not open for further replies.
  1. Reckless

    Reckless Won't take the easy road

    Joined:
    Jan 11, 2013
    Posts:
    2,113
    PokéPoints:
    ₽666.6
    So you may be thinking of setting yourself up to head down the road to computer programming. See these guys? They're two, equally important concepts, that any programemr worth their salt should ideally be well acquainted with. Architecture and 'good' code. What distinguishes them?

    Architecture - as in the construction of buildings, this is essentially the 'blueprints' to a conceived computer system. In essence, it will determine what hardware and software such a system would contain, how the physical hardware would be utilized by the onboard software, and what other technologies it would be compatible with. One of the most widely used architectures in effect today is the Von Neumann architecture; comprised of your memory storage, control unit, arithmetic logic unit + accumulator and your BIOS. This type of architecture uses the stored program concept, which basically means programs and data can operate on the same memory storage of choice (usually HDD or SSD)

    Ohhh! Sounds like heavy stuff! But what's a house without design plans? Or a car without a schematic?

    But wait! What of 'good' code, then?

    Code - A set of human-readable instructions that is translated into bytecode. If you're using a .NET language like C++ or C#, this type of bytecode would be CIL. Once you got that, it's run on the CLR at execution time, and the bytecode is converted into machine code instructions via JIT compilation.

    Yeeeesh. Ain't this stuff ever gonna get light?

    Code makes technology do stuff. Code can be as simple as;


    Code:
    cout << "Hello World.\n";
    Or complex enough to implement class hierarchies or be told to manipulate serialised binary files by reading in the data, processing it and then saving the changes to the new file.

    That's 'code'.

    What comprises 'good' code then, is code that follows the usual conventions and general programming practices. E.g. use of camel casing, accurate variable and function names, be displayed in bite-sized chunks rather than unyielding walls of text, be tabbed & spaced out, and also features comments, which would allow another programmer to come along and see what the original programmer had intended for a certain function or the like to behave. Good code should also be 'future-proof', allowing other programmers to easily come along and change aspects of a system in order to prolong its usefulness. Most important of all, good code should be vigorously tested, and not simply compiled once or twice. After all, you wouldn't deliver to a client a plane without wings or jet engines, would ya?

    So then, after you've digested all that mush, or it may be the case that you were already aware of these important aspects of programming, regardless of my rambling, I'll ask thee this;

    Which is more important; Good architecture or good code?

    ty 'n' gn o7
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. East

    East Look to the Stars

    Joined:
    Nov 14, 2014
    Posts:
    1,785
    PokéPoints:
    ₽742.2
    Honestly, I think that good architecture is of more importance. Good code is what makes everything easier to understand, yet architecture is what makes a program work. However, both are undoubtedly necessary in the grand scheme of programming--good architecture is important for organization as well as getting the program to work, and good code is necessary for readability. Readability is important for both the programmer and anyone else reading the code.

    For example, if you wanted to print a String on one line, and the indices of each character in that String in the following line, this is a bad way to do so: (keep in mind this is Java)

    String bologna = "Hello, world!";

    System.out.print(bologna + "\n");

    for (int dankMeme = 0; dankMeme < bologna.length(); dankMeme++) {
    int[] tickTock;
    tickTock[dankMeme] = dankMeme;
    System.out.print(tickTock[dankMeme]);
    }

    A much better way is:

    String output = "Hello, world!";
    int lastIndx = output.length() - 1;

    System.out.println(output);

    for (int x = 0; x <= lastIndx; x++) {
    System.out.print(x + " ");
    }

    An even more relevant example is the construction of classes and their association to subclasses:

    public class Rectangle {

    public Rectangle() {
    //implementation
    }

    public area() {
    //implementation
    }

    public perimeter() {
    //implementation
    }

    }

    public class Square extends Rectangle {

    public Square() {
    //implementation
    }

    }

    public class Parallelogram extends Square {

    public Parallelogram() {
    //implementation
    }

    }

    Sure, there are numerous cases of good code/code etiquette, but the architecture is messed up. Below is an example of "short code" that doesn't practice code etiquette, but it's far more useful and applicable.

    class Parallelogram {

    Parallelogram() {
    //implementation
    }

    void perimeter() {
    //implementation
    }
    }

    class Rectangle {

    Rectangle() {
    //implementation
    }

    }

    //And so on...

    In my personal opinion, architecture > good code.
     
Thread Status:
Not open for further replies.

Share This Page