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

Does /g/ write clean code?

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: 148
Thread images: 17

File: clean code.jpg (31KB, 386x499px) Image search: [Google]
clean code.jpg
31KB, 386x499px
Does /g/ write clean code?
>>
Yes, always.
>>
File: 1482197921100.jpg (21KB, 600x579px) Image search: [Google]
1482197921100.jpg
21KB, 600x579px
>>58693882
REEEEEEEEEEEEEEEEEEE
>>
>>58693856
Of course, by my own definition of 'clean', not the one of that memester.
>>
>>58693856
>clean code
>"reading few jumps and multi option procedures is too hard for me"
>>
>>58694951
>not the one of that memester
How does it differ?
That book gives pretty consensual advice.
>>
>>58696064
You're like those C retards that answer calls for guaranteed memory safety by "just code better".

Expressiveness is an inherently finite resource, wasting it because you can't be arsed to do some architectural work that will help you down the line is hardly the best way to go about things.
>>
>>58693984
wanna know how I know you're fat?
>>
File: 1247615480539.jpg (19KB, 407x405px) Image search: [Google]
1247615480539.jpg
19KB, 407x405px
>>58696380
>>>/b/
>>
>>58693856
Bob Martin is a gigantic piece of shit.
>>
>>58693856
Depends on if it is a dirty script for myself, or some code for an open source project or as part of the codebase for my job.
>>
I bought that book and never read it. Like so many others.
>>
Nigga I'm paranoid. If w3c validator shows a single warning in HTML I immediately correct it. If Visual Studio has a single warning I immediately correct it.
>>
Yes, because of code reviews
>>
>>58696297
It's obviously packaged in a way to shake money from you suckers - called degrees. Like a methodology talk.
The actual content is either obvious stuff - at least it's pretty obvious to me, but then again I have the X300 phsychoprogrammical self reflective impropability drive - or stuff that harms the source code when overdone.
>>
http://www.duckware.com/bugfreec/index.html

Lots of books about clean code.
>>
>>58697684
Visual Studio bitches at everything. I am just waiting for when it throws a warning that the program you just typed up is not compatible with the current windows version. /s
>>
>>58697904
>code reviews
What did he mean by this?
>>
>>58698099
Don't worry about it - only happens to people with jobs.
>>
>>58698165
Safe then.
>>
>>58697559
N
O
T

ARGUMENT
N
>>
>>58693882
>He doesnt oneline it
>>
>>58697644
This.
>dirty script
Throw in a few jumps here and there, somewhat ugly code.
>open source project
Spend days reconsidering variable names
>job
Use randomly generated variable names and otherwise obfuscated code, keep documentation and the real names on my phone. Good luck firing me now.
>>
File: 1465594439405.png (174KB, 1920x1080px) Image search: [Google]
1465594439405.png
174KB, 1920x1080px
>>58693856
My code is so clean it doesn't even exist
>>
>>58698823
>python spacing
>>
>>58698868
top bait
>>
<CODE>
void stringStutter(string s, int length){

for (int i = 0; i <= s.length(); ++i)
{
cout << s.substr(i, 1);
Sleep(length);
}

}

void stringStutter(string s){

for (int i = 0; i <= s.length(); ++i)
{
cout << s.substr(i, 1);
Sleep(100);
}

}

void stringStutterL(string s, int length){

for (int i = 0; i <= s.length(); ++i)
{
cout << s.substr(i, 1);
Sleep(length);
}
cout<<endl;
}

void stringStutterL(string s){

for (int i = 0; i <= s.length(); ++i)
{
cout << s.substr(i, 1);
Sleep(100);
}
cout<<endl;
}
</CODE>
>>
>>58699050
Determine what s.length() is and place it in your for condition. Execution will be faster
>>
>>58698823
I want this.
>>
>>58698823
You stole this from the other thread, thievo.
>>
>>58698823
> Still using cases instead of maps
>>
>>58699192
Not him, but to do this would be to store it in a temp variable no?

Is that the only overhead for the increase in execution time?
>>
File: 1485563184056.gif (402KB, 211x199px) Image search: [Google]
1485563184056.gif
402KB, 211x199px
>>58693882
>>
>>58693882

I have seen some powerful, highly paid tech gurus that only write shell scripts and regex.

You think you are joking, but...
>>
File: nice clean code.png (22KB, 625x342px) Image search: [Google]
nice clean code.png
22KB, 625x342px
What is the cleanest language
>>
Half of /g/ shills C, and writing clean code in C is pretty much impossible for things more complex than fizzbuzz, so probably not.
>>
>>58693882
What cute font is this?
>>
>>58700975
>Implying
cat-v.org
The only way to write clean, simple software is C
>>
>>58701053
Have you ever looked at vim's source code? Or any big C program, for that matter? It's always either spaghetti code or a poor attempt at emulating OOP.
>>
>>58701072
>vim
>big C programs
>proper C
Any good large software should basically just be small software joined together, like the UNIX philosophy
I know that it's not like that in practice, because people seem to think bigger is better, but it should be
>>
>>58701018
Profont
>>
>>58701084
What about the Linux kernel? I honestly don't know, how bad/good is it?
>>
>>58700926
"Clean" is a very vague term, but I'd say C# is up there.
>>
>>58700926
Lua
>>
>>58701110
I've only heard it describes as 'its okay'
>>
>>58700926
https://en.wikipedia.org/wiki/Clean_(programming_language)
>>
>>58698763
kek
>>
>>58700926
vb6 is quite clean t b h
>>
>>58698823
>not defining static variables with the switch/case digits in them
>>
>>58693882
10/10

the problem with this code is vim, who doesnt have indenting for wrapped lines.
>>
File: 1483480764727.jpg (57KB, 482x549px) Image search: [Google]
1483480764727.jpg
57KB, 482x549px
>>58693856
Not really. I'm trying to improve though.
>>
Reminder that -Werror is almost always justified
>>
Rate my fibonacci:


public static void main(String[] args) {
fibonacci(10);
}

private static void fibonacci(int nth) {
fibonacci(nth, 0, 1);
}

private static void fibonacci(int nth, long first, long second) {
if (nth == 0) {
return;
}
System.out.print(first + " ");
fibonacci(nth - 1, second, first + second);
}
>>
>>58693856
I don't write code using functional languages,
so yes - I do write clean code
>>
File: 1450064898563.jpg (66KB, 526x400px) Image search: [Google]
1450064898563.jpg
66KB, 526x400px
>writing clean code
>not writing unmaintainable spaghetti code so no one else knows how it works
>job for life as the company is too scared to fire you
>>
>>58703880
https://www.doc.ic.ac.uk/~susan/475/unmain.html
>>
>>58703871
>mutation
>clean
>>
>>58703880
I've worked at a company that still had a 1980s mainframe and the most incomprehensible code known to mankind, all maintained by a single unfireable engineer who designed the system, it was literally like an IRL version of Dilbert
>>
>>58700477

> Using costful abstractions where isn't needed
>>
File: 1483217732813.png (767KB, 700x700px) Image search: [Google]
1483217732813.png
767KB, 700x700px
>>58703890
>Make sure that every method does a little bit more (or less) than its name suggests. As a simple example, a method named isValid(x) should as a side effect convert x to binary and store the result in a database.
>If, for example, you were writing an airline reservation system, make sure there are at least 25 places in the code that need to be modified if you were to add another airline. Never document where they are. People who come after you have no business modifying your code without thoroughly understanding every line of it.

Kek this is some evil shit. I'll read the whole thing later.
>>
>>58700554
Pro tip: remove the calls to Sleep for blazingly fast execution speeds
>>
>>58703880
This. I use random variable/function names and remove any comments I come across. All the documentation (including the real names) is on my phone.
>>
>>58699050
Use code tags for the love of god.
>>
Trying to keep it at one level of abstraction per function can be bothersome.
Also his absolute hardon for splitting EVERYTHING into tiny functions be too zealous, and sometimes detrimental to code readability - IMHO.
>>
>>58703857
Pretty terrible. Have to actually read the code to understand what the function does. And then it turns out that it has two responsibilities instead of one.

Read the book anon.
>>
>>58693856
I never had the privilege to work on my own project from scratch.

Instead I just inherited a project in "just fuck my shit up" state, full of deprecated and outdated methods and functions, and legacy code you know you can't delete because something just MUST depend on it.

it is also full of comments like "please do not use this :(" and "warning! this method contains shitcode and evil js giving no f#cks about this and that doing out-law gangster sh#t".

Cut my life into pieces.
>>
>>58693882
Looks better than my code. But I'm coding alone in my company.

Have fun tweaking my code after I change jobs.
>>
>>58698763
Randomly generated variable names
Using that from now on.
>>
>>58704699
My condolences for the loss of your sanity.
>>
>>58704622
>Pretty terrible
the task is to print the nth factorial
how would you have done it?
>>
>>58704731
Bonus points, use a wordlist to generate variable names like pointerFunctionInstanceHandler.
>>
>>58693856
No. And then yes.
>>
File: 1478604784377.png (66KB, 597x255px) Image search: [Google]
1478604784377.png
66KB, 597x255px
best formatting style coming through
>>
>>58705093
kill
>>
>>58693856
i designed our buildsystem in a way that forces our devteam to not submit stupid hacks unnoticed and forces them to produce somewhat clean explainable code

i myself obviously work not always in the constraints of this system and produce one unmaintainable badly named hack after the other some days if i know its "run once then throw away" code

clean code is for long term projects/libs or for people you dont trust to know when a hack is necessary/acceptable and dont trust their ability to produce a good hack/code in general
>>
>>58705093
What happens if one line is too long?
>>
>>58705123
you redesign your code until it fits.
if you have to you change the spec.
>>
>>58705093
why not simply switch to python?
>>
>>58704979
Kek this is going to drive someone real nuts.
>>
>>58698823
>curly in same line as function header
>indenting cases
kys
>>
>>58700926
Haskell
>>
>>58701053
cat -v is just the "we're edgy Atheists" philosophy website. The website that's actually about programming is suckless, and yes, it's breddy gud.
>>
>>58703814
Not with GCC and glibc since optimization flags actually trigger some warnings such as Wunused-result (try it with fgets and -Os). GCC is a hell of a piece of shit.
>>
>>58704622
>Have to actually read the code to understand what the function does.
lol?
>>
>>58698823

>Not using prototypes
>>
>>58698763
fire you? they are going to sue you man.
>>
>>58693856
I don't follow any sort of "style" dogmatically. In general yeah, I try to make sane architectural design choices that won't make the code an unmaintainable clusterfuck. It's very easy to go far overboard with "extensible" and "clean" code while following some dude's rules blindly in my experience.

Basically you should use common sense in regards to the program you're writing and its requirements, any decent programmer with some experience should be able to do this. If you're new you should try to pick up some good practices, but always think about what you're doing and don't apply any sort of rule blindly if it doesn't make sense to you. If you're in that situation it can only mean 2 things: you either don't properly understand what you're doing or the rule is retarded in the specific scenario, as such you should think about it some more.
>>
>>58693856
My code is so dirty. I always have to shower after coding or seeing my own ...
>>
>>58705290
Absolute madman mode:
Have an object named after something that should be a function
Have a variable named after something that looks like an argument
-> instead of using varSomething, use GetWebsiteInterfaceHandlerFactory(clientReference)
Also, use Il1| O0 ,. '` similarities in these and have the """""functions""""" change """""return value"""" from their """"arguments""""" periodically.
>>
>>58705639
I'm not doing anything illegal. Besides, have fun paying for translating my notes.
>>
>>58706256
>I'm not doing anything illegal
yeah you are people get sued for this all of the time. i don't care, personally, but FYI if you work for a company that can afford lawyers they will take legal action against you if it comes to that
>>
>>58693856
That book is extremally exaggerated, and it's basically "Coding in Java".
>>
>>58706360
Maybe in the USA.
>>
>>58704933
The task is to print the first 10 fibonacci numbers.

public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println(fibonacci(i) + " ");
}
}

public static int fibonacci(int n) {
// calculate and return the nth fibonacci number
}


If you're worried about this having worse time complexity, memoize the previously calculated values.

>>58705523
Do you not think that's a serious problem?
>>
>>58693856
>agile.
>JBGE
there ya go
>>
>>58706360
>people get sued for this all of the time

elaborate
>>
>>58703857
>if (nth == 0)
nth <= 0
>>
File: 99per.jpg (899KB, 2560x1702px) Image search: [Google]
99per.jpg
899KB, 2560x1702px
>>58706563
not recursive
not memoized
>>
File: sbcl.jpg (38KB, 768x384px) Image search: [Google]
sbcl.jpg
38KB, 768x384px
>>58700926
Common Lisp
Then
Scheme or Guile
>>
>>58694951
>>58696297
>>58696064
Guys. This book is not for you. It is for poo in the loo Pajeet dumb fucks. If we seriously want to advance the state of software security software must not become easier but instead absolutely trivial. It is the only way to prevent the IOT botnet apocalypse.

>>58700926
Ada SPARK

>>58703880
Get thee behind me Pajeet.

>>58703891
It compiles down to pure functional SSA anyway so what's the problem?
>>
>>58706463
This. Most people don't live in a country that's ruled by corporations and lobbyists.
>>
>>58698087
That would be a useful feature tho. If your still deving for only old versions you are part of the problem.
>>
File: 1484374555445.jpg (165KB, 1058x705px) Image search: [Google]
1484374555445.jpg
165KB, 1058x705px
>>58706237
Why not just include the whole fucking dictionary while we're at it?

AppleBananaTrainCondomNigger(Airport)
>>
>>58700926
I find ruby to be the cleanest as far as syntax and susinctness. Tho I guess a language like c# could be considered cleaner, tho more verbose.
>>
>>58707052
Because they need to pass for coding terms at first glance. Maybe use Markov chains generated from open source project variable names.
>>
>>58703880
My current job is as a consultant rewriting the code base after they fired their in house guy that did that.
>>
>>58700926
asm. There's literally no cleaner language by definition.
>>
>>58707094
Their in house guy wasn't good enough at writing bad code.
>>
>>58705093
>when you have to write php but wish you were using ruby
>>
>>58707094
Do you think about killing yourself sometimes, or is the pay just that good?
>>
>>58707128
I work a similar job. I am a college intern and I am making more than my dad does.
>>
>>58693856
I never heard about this book so I just googled it and found an interesting site. I guess I just read the preface to the book and it states that some people believe that code will soon be generated by programs using specifications the user inputs. I'm relatively new to programming and I've though about that concept quite often, but really, how realistic is it?
>>
>>58707090
GNUInterject(Linux)
>>
>>58707142
That program is called India, anon.
>>
>>58707141
Wish I hadn't smoked weed, got a gf and dropped out in the late 90s.
I always had A grades in informatics.

Guess you can call me a nerd jock.
>>
File: 1461728360949.jpg (104KB, 547x458px) Image search: [Google]
1461728360949.jpg
104KB, 547x458px
>>58696352
memory masher detected
>>
>>58706256
Sabotage is illegal
>>
>>58707176
>in the united cuck states writing working code is considered sabotage
>>
>>58707161
I just googled for an actual program called India. I feel stupid now. Thanks.
>>
>>58707128
It kind of sucks, but then I remember I get paid $50 an hour and get over it.
>>
>>58707223
We all feel stupid on here sometimes. That's what makes /g/ interesting.

One of the reasons why I come here is to learn from people who know shit I don't know about. No other board offers this.
>>
>>58707234
I'd suck cocks for less than half of that tbqh. Living in a time where "being good with computers" is nothing special anymore is hard for me because that's the only thing I'm good at.
>>
Concerning programming: Why even learn it? Is there anything that hasn't been done before? In the 70s and 80s this was all exciting and new but by today we have basically squeezed everything that's possible out of computers.
>>
>>58698165
genuinely laughed 10/10
>>
>>58707261
They literally just discovered a way to turn Hydrogen into a metallic state days ago.
>>
>>58707289
And that's related to programming... how exactly? What I meant was, every problem that a computer can potetially solved can already be solved by a computer. We got computers in our fucking toasters. It can't go much further.
>>
>>58707368
Zero loss and extremely low heat buildup. It's not a direct step, but it does increase the potential maximum speeds, which could lead to more intensive applications.

(also extremely high performance rocket fuel, but this is another story)
>>
>>58707260
Do you know programming at all? Even basic Web dev jobs will start out at minimum $50k in any of the top 100 population centers these days.

Convincing people you know enough to get the first one isn't always easy f you don't have a degree but a small portfolio works well.
>>
>>58707289
Electric cars just btfo?
>>
>>58707692
It was like 1/100 the diameter of a human hair, so it will take a while to mass produce.
>>
>>58707674
What if I do know my shit, but haven't done anything after dropping out of school 16 years ago because of my crippling depression?

I've been to the agencies in Germany and basically they told me that I should accept cleaning animal shit off the streets for 1 euro per hour. I'd rather kill myself before doing that.
>>
>>58707761
Anyone want to employ me? I'm a desperate NEET at this point. I'm not joking.

Seriously I'm total sick of getting offered jobs like collecting trash or polishing streetwalks for 1 euro per hour.
>>
>>58693856
>writing a class if a function has 3+ args.
Yeah, no.
>>
File: 1483932188525.jpg (5KB, 191x184px) Image search: [Google]
1483932188525.jpg
5KB, 191x184px
>>58693856
Uncle Bob's book was genuinely awful with terrible, winding examples, unjustified changes, and other coding and literary nonsense.

If you want to write clean code, read Martin Fowler's Refactoring and be done with it.
>>
>>58707761
>>58708136
Most dev are on somewhere on the spectrum. Just start putting together a few basic websites in php then start aplying. If a place turns you down find out why and improve in that area.
>>
Does anyone have Object Oriented Programming memes?

There was a decent one about flying a kite or something
>>
yeah always

great book btw
>>
>>58693856
I dream in code.
>>
>>58696352
If you want guaranteed memory safety you have to code functionally
>>
>>58708790
>Martin Fowler's Refactoring
I'm currently starting to read it since we'll be doing a big codebase refactoring for this year.

Any other recommended books or material (talks, anything) that I should peruse, kind anon?
>>
>>58702876
It does as of vim 8
>>
File: PSP.jpg (31KB, 378x499px) Image search: [Google]
PSP.jpg
31KB, 378x499px
Yes, I do.
>>
>>58707094
How did you get that job and what are they typically called when advertised?
>>
>>58714687
A cuck
>>
>>58701213
fuckin love lua
>>
Hey I actually just go to the Concurrency chapter. It's a great book so far, a nice reminder to keep yourself in check.
>>
>>58706816
> He doesn't know how to generate fibonacci numbers without recursion
Enjoy your stack overflow
>>
My personal style
Game_t *Game_New(bool init)
{
Game_t *game = malloc(sizeof(*game));

if (!game)
{
return NULL;
}
else if (init)
{
Game_Init(game);
}

return game;
}
Thread posts: 148
Thread images: 17


[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.