[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

There is a fundamental problem with the way software design is

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 118
Thread images: 11

File: yandere simulator.png (149KB, 828x801px) Image search: [Google]
yandere simulator.png
149KB, 828x801px
There is a fundamental problem with the way software design is taught at the university level.

Even self-taughts are guilty of this shit.
Why are competent programmers so hard to find?
>>
>There is a fundamental problem with the way software design is taught at the university level

Which is?
>>
>>58640112
because today every incompetent oaf is told they can be a programmer after a 1 day crash course/bootcamp
>>
>>58640112
Is the poster of this actually Yandere Dev?
We may never know!

I mean, he did come to /v/ for the initial stuff.
Why not /g/?

What is this written in, though?
I don't normally see PascalCase.

Why is it using else ifs instead of a switch? This isn't Python...
(although, desu, Python is pretty good. I use it for my DiscordBot)

What is with the direct use of class variables, though? Why are you not encapsulating it and using an accessor function??
>>
do people not know how to write a function?
>>
>>58640112
Competent programmers were shit programmers too once.

It's most likely that the competent programmers don't give a shit about you.
>>
>>58640112
I only know ultra basic stuff by reading shitposts and never programmed anything but i think that he should've used switch instead of ifs and else ifs, right?

pls no bully
>>
>>58640112
How would you do that in your pic better?
>>
>>58640386
Not OP, but I'd:
>use a switch instead of else ifs
>NOT directly access data, but use some data hiding and stuff to force use of accessor functions, because it's safer
>use better descriptions for those, but I'm not really 100% sure why he's doing it that way... Maybe an ENUM if it actually needs to print that somewhere

probably a few other things, but rly I'd needa see more of the code to decide on further actions to take.
>>
>>58640264
He's a victim of the OOP meme. He wrote the witness property as a literal string to reference instead of as enumerable states or something similar.

>>58640386
See above.
Or more ideally, this.Witnessed should be an event function that determines what kind of object was witnessed inside the method, and not be an attribute.
He's effectively using an adjective as a verb, which is bad.
>>
That 1000 prints a second was haxe not cpp. mb
>>
>>58640434
Switch statements are no shorter than if else statements and offer much more opportunities to fuck up idiot.
>>
>>58640529
But then the hash map is uneven.
>>
>>58640112
>(float)6
>>
>>58640583
Yeah but switch statements are optimized together. The ifs could do a better job as a standalone decision tree but you might get lucky with a switch. maybe youll land some unions.
>>
>>58640583
which fuck ups? not puttiing a break after each case?
Switch cases are much more efficient as if else blocks also more readable. Sure having more than 20 cases can become unreadable but its still better as reading all those if else boolean operations

Also why is he not using method overloading??
>>
>>58640583
Switch statement ARE shorter than else-ifs...
at least in terms of what you need to read

And in this case, they ALSO would work well since several of the the GameOverCauses are the same.
4 of them are Insanity, and 2 of them are Weapon.
>>
>>58640661
how would method overloading help here?
>>
>>58640661
>>58640748
Yeah.... I'm not sure what that has to do with anything...

I mean, I'm sure there's SOME place in the code that overloading might make sense, but I don't see it in that pic
>>
Maybe it's because im a bit of an aspie but I never did this sort of stuff even at the beginning, I am self taught and been coding since 12, it's the schools that teach this way and the teachers being incompetent morons the kids dont learn shit
>>
>>58640748
by not using the second and third parameters, if he is going to use it EVERYWHERE anyways.
just make a method UpdateLabel(String) call UpdateLabel(string, 1, (float) 6).
I saw he used something other than 1 so hhe can call UpdateLabel(String, int) call UpdateLabel(String, int, float)

it increases code readability and you are also not wondering why he typed it everywhere.
>>
>>58640125
>Which is?
In my experience, the problem was that software design wasn't taught.

>>58640434
there are also many cases that are very similar, which should be put together or at least extracted to a function that handles the minor variations.

why the fuck is this done by strings anyway? If you're not taking an action based off a string typed by the user, then you should be using an enum or something along those lines. Strings are inefficient and error prone.
>>
>>58640386
use a db
>>
>>58640244
>>58640434
>>58640583
>>58640627
>>58640656
>>58640661
>>58640722
>>58640824
>>58640866
This is why you are all on /g/ right now.

The best solution is do ditch the conditionals and use an object to pass the values. Define your data separated from your logic branches.
For instance:

consider the object (JSON),
{
thingsWitnessed: "Weapon and Blood and Insanity",
subtitleText: "Teacher Insanity Reaction",
gameOverCause: "Insanity",
}


So instead of conditionals, find the object of thingsWitnessed == this.Witnessed and pass in that object's subtitleText and gameOverCause attributes.
>>
File: 1483922304051.jpg (62KB, 624x591px) Image search: [Google]
1483922304051.jpg
62KB, 624x591px
>>58640927
This is the correct answer.
>>
>>58641005
>>58640927
>using a db in a single player game
You might as well just use a hash table, instead of loading up an entire db application to manage a few tiny tables.

This is like loading up chromium to check for updates. It's a bit easier, but it adds a ton of bloat.

>>58640933
if you used an enum for things witnessed, you could just pull it and its attributes out of an an array.
>>
>>58640933
>comparing strings
>iterating over useless JSON objects
t. javascript artisan

public string GetSubtitleText(WitnessState state)
{
const string reaction = "Teacher {0} Reaction";
const int maxWitnessStates = 6; // Can be retrieved dynamically, done here as const for convenience

for (int i = 0; i < maxWitnessStates; i++)
{
WitnessState check = (WitnessState) (1 << i);
if ((state & check) != 0)
return string.Format(reaction, check);
}

return null;
}

// Ordered by importance.
[Flags]
public enum WitnessState : byte
{
Insanity = 1 << 0,
Weapon = 1 << 1,
Blood = 1 << 2,
Lewd = 1 << 3,
Trespassing = 1 << 4,
}
>>
>>58641143
you don't fucking put the data in the code what the fuck is this bullshit again
>>
>>58640112
there is a fundamental problem when you canĀ“t even put in english what the fuck are you talking about.
>>
File: 1459055987116.gif (512KB, 480x270px) Image search: [Google]
1459055987116.gif
512KB, 480x270px
>>58641149
I wasn't suggesting an implementation, only a higher level design idea.
>>
>>58641149
What language is that?
>>
>>58641273
C#, same language as in OP
>>
>>58641234
>don't put the data in the code
what part of this is data? things witnessed?

Why wouldn't you put that in the code? If turing complete behavior is determined by the thing witnessed, then there's no point moving it outside of the code.

If it needs to do anything more complex than just output the title, like start a specific AI routine, you're going to need an enum or polymorphic object somewhere to deal with it.
>>
>>58640244
It's got to be Java, as C++ defines "this" as a pointer, not a reference (meaning its members are accused with the arrow instead of the dot operator). I'm pretty sure you can't do testing against strings in a switch, though that could be avoided if they used enums instead of strings (which they should be doing anyway, since it would save a lot of space; only advantage to using strings as enums is that they're printable).

And PascalCase in this instance is unusual, in any modern language it's usually reserved for class types (String, BitInteger, etc) with camelCase or snake_case used for everything else.
>>
Yandere Simulator is written in C#
>>
>>58641461
It's C# so yes "MS Java"
>>
>>58641461
>>58641307
apparently it's C#. You weren't far off though.

>PascalCase in this instance is unusual
not in C#. C# is a special snowflake so it uses pascale case.
>>
>>58640244
Python. The sjw special snowflake of languages.
>>
>>58642460
why is that?
>>
>>58642635
He's a faggot talking shit.
Forget about it.
>>
>>58640933
In my defense, I was approaching the question of which is more optimized to serve his interests.
>>
>eva rused /g/ into fixing his code
haha, suckers
>>
>>58640933
It makes things a bit more easily extendable but also harder to read, since the information you need to make sense out of what's written is now spread over multiple files, as opposed to all of it fitting on one screen previously.

It's always a tradeoff between simplicity and extendability, and the choice should not always be in favor of extendability as you're preaching.
>>
>>58641149
I have a small question. Why are you using shift operators when you can do it 'normal' way? Like just putting 1,2,3,4... in that enum.
Is it some kind of preference?
>>
File: yandere.png (2MB, 2672x6068px) Image search: [Google]
yandere.png
2MB, 2672x6068px
>>
>>58643869
Someone already did a long time ago but apparently he is adamant on sticking with his terrible code and complaining that adding stuff and progressing would take too much work
>>
>>58640112
if statements are faster than switch
fuck your coding standard
>>
>>58644471
barring maybe doing it for prototyping reasons, the compilation for that block will involve calls.

Not him, btw.
>>
File: 1485064039566.gif (1006KB, 222x162px) Image search: [Google]
1485064039566.gif
1006KB, 222x162px
>>58644669
Fewer calls*


>tfw furor calls
>>
>>58644471
Because you can combine the enums that way, because each value is on its own bit. So you could say the witness state is eg. Insanity & Weapon.
>>
>>58644645
> computed jmp statement is faster than if/elses.

How do you say "your argument is not necessarily true because switches can be optimized in ways if/elses cannot"? in English?
>>
>>58641461
In Java it would be
> this.witnessed.equals("some string")

But yeah, you weren't far off.
>>
>>58644837
Wait.

Are you saying that enums aren't proper types in C#, but just a fucking integer value?

I feel bamboozled. How come nobody is picking on C# programmers for this?
>>
people that endlessly labor over making their code more "efficient" end up increasing execution speed by 5% and decreasing readability by 50%
>>
Really, the worst part about this code is that it isn't properly documented/commented...
>>
>>58644866
> How do you say "your argument is not necessarily true because switches can be optimized in ways if/elses cannot"? in English?

How do you say "jump to variable address instruction used in switch implementation eliminates CPU cache while a bunch of jumps to known addresses produced by if/else keep the cache"? in English?
>>
>>58644956
It's written in a way that you don't need comments to understand it.
>>
>>58644988
Spotted the web dev! jk

Isnt that when you bust out function pointers over regular calls to instated functions or lambdas instead?

Really the best solution here is manual memory allocation.
>>
>>58640434
>>58640244
>accessor functions
t. java fag
>>
File: 1459522408305.png (4KB, 300x300px) Image search: [Google]
1459522408305.png
4KB, 300x300px
>>58640292
>>
File: 1459522726034.png (742KB, 2992x2992px) Image search: [Google]
1459522726034.png
742KB, 2992x2992px
>>58642460
>>
>>58644882
I don't know about C#, I just said that because it's a pretty common thing in C/C++.

But yeah, it's probably just a integer underneath.
>>
>>58644471
Because so I can combine it with OR operators like
WitnessState myState = WitnessState.Insanity | WitnessState.Lewd;


You can see I declared the enum so it inherits byte type, so it's basically a byte underneath.
>>
>>58640112
>Why are competent programmers so hard to find?
Because their classes give them languages that are too easy to use and therefore don't serve as filters. Talentless subhumans breeze through university classes with their training wheels on, and when they get to the real world they pollute the job market with their inferior abilities, instead of failing out at the 101 level and flipping burgers for the rest of their lives.
>>
>>58642635
I think he's talking about code blocks being identified by indentation
>>
>>58640112
>calling strcmp 5000 times instead of comparing ints
>>
>>58640112
Why does this always happen in C# games?
Terraria does the same shit. Is there some code generator tool that does this?
>>
>>58648478
I'm in 101 and we're using c++ how do I do
>>
>>58641005
Is the yoshi supposed to look like a condom on a penis?
>>
>>58644592
What is wrong with this?
>>
>>58649036
It's some decompiled code. It's bound to look shitty.
>>
>>58649036
It's a 2.5k line function that runs every frame
>>
>>58640112
>>58644592

I don't see anything necessarily wrong with these.
>>
>>58644888

T. Novice programmer here. Why does readability have such a premium placed on it? Why not just have good notes/documentation while having the best code you can write? I understand dealing with legacy code, but at the same time "readable code" without documentation is shit to deal with.
>>
>>58641461
it's c#. The "this" is from reflection
>>
>ctrl+f
>prime numbers
>Phrase not found

Holy shit does noone here know anything about efficiency?
>>
>>58649286
Explain.
>>
>>58649126
Then you're part of the problem.
>>
>>58649345

this.Witnessed is an integer that gets multiplied with a prime number every time something is witnessed. To check what is witnessed you use integer division with consecutive primes and order the prime to event map such that important events get checked first.
>>
>>58649482
That's retarded.
>>
>>58640112
>There is a fundamental problem with the way software design is taught at the university level.
NO
> Why are competent programmers so hard to find?
because programming is just a tool. you need to seek people with the ability to efficiently solve problems. this is the problem. also university programming degrees are just meme
>>
>>58649482

not a programmer but even i can understand the genius behind this.
>>
>>58649505

You're welcome to try to come up with a method that'd execute faster and still contain all witnessed events.
>>
>>58647618
Why would you declare it as a byte? You typically don't gain any performance or reduce your memory footprint by using a type size smaller than word size (64 bit on AMD64), if you're not storing an array of the type.
>>
>>58649585
In the case he wants to store it in an array/on disk/send it over network?
>>
>>58649482
Just use powers of 2 instead of primes. Integer divisions are expensive. bitwise and is almost the cheapest instruction that exists.
>>
>>58649568
A bitmask.
>>
>>58649615
Is saving 7 bytes on a network operation with a 64 byte header (assuming TCP) important?
>>
>>58649656
Typically games use UDP so I guess every byte counts.
>>
>>58644882
>How come nobody is picking on C# programmers for this?
The fact that you think that this is some sort of vector for ridicule shows clearly your ignorance on the subject.
>>
>>58649656
could be

If there was nothing to lose from doing it, well, yeah I'd do it. There's nothing wrong with greater efficiency that comes without a cost.
>>
File: 1484256871099.jpg (39KB, 400x388px) Image search: [Google]
1484256871099.jpg
39KB, 400x388px
>>58649568
An array...
of...
...
booleans.
>>
>>58649665
UDP is only about 12 bytes shorter than TCP though.

>>58649684
>There's nothing wrong with greater efficiency that comes without a cost
There's a potential maintenance cost of using a type that limits you to 8 values for the enum instead of 32 or 64. Having to go back and switch type sizes often causes problems.

bytes are also slower to compute to some degree. On x86 or AMD64, The compiler typically has to XOR the register before loading a single byte to avoid a dependency chain on the upper bits of the register, while it doesn't need to do this for a 32 or 64 bit value.
>>
File: 1466624707921.jpg (32KB, 399x388px) Image search: [Google]
1466624707921.jpg
32KB, 399x388px
>>58649803
When sending an array of those, the size will grow much faster.
I guess it depends on what OP wants to do with it. If he wont use more than 8 he can always cast it to byte to store/send.
>>
>>58640351
A switch may have looked neater, but the point is that there are several redundancies that could have easily been consolidated into fewer lines.
>>
Third year Computer Science student from the UK here

Personally, I think this is down to the fact that it's so easy to get into a Computer Science course, and even easier to stay once you're already in. They have to teach at the lowest level in the class which is usually someone who can barely grasp the object orientation, let alone programming languages themselves.

The way they have to teach is basically "let's get everyone to actually complete this task" which is usually, as in the picture, code that 'works' but is inefficient and crap

If you think those if statements are bad, you'd hate to see how some people work with data structures

I don't mean to sound horrible here but that is honestly the reason teaching isn't very advance and Masters concentrate on good code, which in my opinion should be a major part of the degree. It should be far harder and if you write crap code you shouldn't be able to get anything more than a pass.

rant over
>>
>>58649861

the idea of object orientation**

I need more coffee
>>
>>58649568
masking and bitwise and-ing
>>
>>58649861
you don't need anything more than a pass; companies don't care much, if at all, about your gpa.
>>
>>58640112
CompSci != Software Engineering
>>
>>58649924
A company I interviewed with said they had a threshold of 3.5.
>>
>>58640112
>Even self-taughts
>Even

it's mostly hobbyist retards that are guilty of this, friend
just look at /dpt/, software architecture/design is one big joke for them because writing Fizzbuzzes doesn't require it
>>
>>58649845
>When sending an array of those
>>58649585
>You typically don't gain any
performance or reduce your memory footprint by using a type size smaller than word size (64 bit on AMD64), if you're not storing an array of the type
>if you're not storing an array of the type
>array

why would you store an array of those enums anyway? it's looks like it's part of the global state of the game.
>>
>>58650083
>why would you store an array of those enums anyway
Maybe it could be part of a Person struct, which he could then store in array to track witnesses, or something.
>>
>>58640112
outsourcing obsoleted the old practice of training employees

now you just have indian slaves do everything
>>
>>58649972
I'd be willing to bet they'd waive that for someone with 3-5 years experience.
>>
>>58650137
duh
>>
>>58640112
Surely only complete retards program like this.
>>
>>58649630
This.
>>
>>58650690
Google EvaXephon and click on images.
That's yandereDev
>>
>>58640112
>There is a fundamental problem with the way software design is taught at the university level.
>the way software design is taught at the university level.

>software design
>taught at the university
my sides are in space now, OP
>>
File: flowers-1871.jpg (78KB, 479x1007px) Image search: [Google]
flowers-1871.jpg
78KB, 479x1007px
>support myself financially
>familiar with python
>want to learn how to program for real
>college programs (at least the ones i can afford) are shit-tier

What's the best approach here? Pick up CLRS and work through it in the evenings? I'm pretty good at math, life just took me in a different direction than computers till now.
>>
>>58649141
As a piece of software gets larger you spend more time reading code than writing new code. It pays to have clean well written code because some poor fucker will need to traipse through all the code hunting bugs and modifying behaviours down the road.

Great example happened to me recently; the company I work for hired a contractor while I was off sick recently. The code he wrote is both a mess and riddled with bugs, it's been a nightmare just getting everything fixed let alone meeting our deadlines.
>>
and this kids is why you learn async programming and triggers
this would not be a problem if you were not retarded
>>
>>58651202
How do I into async with C?
>>
>>58651707
tables of callbacks and pthreads. Alternatively you could just do tables of callbacks because doing anything concurrently causes problems
>>
>>58649081
Can you explain this to me?
>>
>>58640112

Im not really proficient in code but why don't you just create a list of these events that you reference through grabbing their index number

im tired but you lads probably get what I mean, would take up alot less code
Thread posts: 118
Thread images: 11


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.