Code monkeys of Sup Forums, how do you go about designing your programs

code monkeys of Sup Forums, how do you go about designing your programs

Did she use tongue?

yes

I usually spend a while thinking about the high-level details about what my program is supposed to be doing and what needs to be done for that to happen.
Then I start writing it.

None of this UML agile OOP crap. Pure procedural programming is much better.

you break it down to be as simple?

>tfw youll never be trumps kid

Usually. Simple solutions that are specific to the problem is better.
There is no point complicating your code to be overly general, unless you're writing a library.

>is better
are better*

but what if the simple solution is inefficient

Das hot mayne.

People with inefficient solutions that meet the deadline keep their job.

t. pajeet

you know where to get some more?

By understanding the problem. Fucking faggot.

:(

but I'm talking useless computation inefficient

If the performance of that solution is important, write a better one then.
This will probably make the solution even less general, but that's not important.

I consider what it is I'm making
then I draw a graph - a physical fucking graph on a piece of paper, be it printer or notebook or whatever the fuck - of how it works, primarily focusing in the flow of the UI and how the UI inputs go from one point to another
If this is too perplexing, I propose you peruse a different hobby. You're never going to find the buried treasure without a map.

do you try to make the code beautiful, or do you not care?

I spend quite a long time trying to make the code elegant.

Yes, ingenuity in simplicity or something along those lines. Cant remember the exact quote now

share an example snippet

I try to make it not look like a fucking disgrace.
If I have a loop, I indent everything in the loop so the person knows that code is part of the loop. I'm pretty sure most compilers care about this anyways so you should be doing it anyways.
I also put comments at the end of loops, decision statements, and functions. Why? Because then that way I can know for sure that, at this point, that part of the code is supposed to stop doing what it's doing. The best part is, at least in good languages, comments are completely ignored by compilers so they don't add unnecessary bullshit to your product's file size.
Naming conventions should be good, and a lot of people will probably bitch at you if you don't useCamelCasing. No one gives a shit if you prefix your functions with the data type, but if it helps you remember then nobody will really care.
And most of all, for the love of God don't write your code so that if you decide you don't need a function and want to rid the world of it entirely, that it makes the rest of the fucking thing fall apart like a jenga tower 9/11.
If that doesn't give you some insight on what the fuck you should be doing, then you're probably better off just doing graphic design.

/thread

Start by writing the data structures for your program, then everything else should just be transformations on your data.

Is it bad that I read this as “designating your programs”?

for example, how would you guys solve problem 15 on projecteuler?

what I first did was create a function, that when given the length of the sides of square, will give a list of pairs consisting of vertices and their adjacent vertices

the hope is that I can use those vertices and their adjacent vertices in order to make a path

I have no idea what to do next though

I just wanna know your guys though process on this problem and how you'd solve it

usually with a lot of glitter and dolphins

mathematical problems aren't programs

Design? What?

Just open up your IDE and start copying and pasting from Stack Overflow until you've finished writing the program.

>for example, how would you guys solve problem 15 on projecteuler?
Well my approach would be to first realize that since I can only move right or down at any step, I can encode my path as something like (0,1,1,0,0,1) where 0 is right and 1 is down.

Since the total number of 0s and 1s is fixed, the only thing that distinguishes the paths is the arrangement. Since the order does not matter, I just need to pick out any ‘N’ spots from the 2N paths, which is 2N over N, or in the case of 20:

λ binom 40 20
1378465XXXXX

I don't understand that last bit of picking out any N spots

Consider the case for 2*2. We have the following paths:

(0,0,1,1)
(0,1,0,1)
(0,1,1,0)
(1,0,0,1)
(1,0,1,0)
(1,1,0,0)


The only difference is which of these 4 steps are ‘1’, i.e. you're picking any two “positions” of the path to be 1, with the rest all being 0.

(This works in general for NxM, not just NxN, too)

The number of ways to pick any 2 out of 4 options is 4 over 2, or binom 4 2