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

CODE REVIEW

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: 67
Thread images: 9

File: 1468277344485.jpg (125KB, 1280x720px) Image search: [Google]
1468277344485.jpg
125KB, 1280x720px
Grade Kobayashi's code skills.
>>
>.get('ip', None)

The None is unnecessary, that is the default.
>>
File: 1465182685613.png (226KB, 331x418px) Image search: [Google]
1465182685613.png
226KB, 331x418px
>>60338800
>>
>>60338800
>self.get
>not pictured in image
>somehow knows what the default value was for the function.
>>
>>60338800
Now it raises KeyError.
> What the hell anon, the others said you knew this
>>
>>60338775
>all that english
>still cant speak it
>>
>>60338775
what language is this?
>>
>>60338775
does w/e language in the picture not have enums or something? why the fuck are all the parameters being passed as strings?
>>
>>60339058
Japanese.
>>
>>60338775
> Non-ASCII comment
> Unnecessary variable extraction
> Way too long line
> Random seed is hardcoded
Code review -2 for the comments
-1 for everything else
>>
File: 1491425762334.jpg (116KB, 1280x720px) Image search: [Google]
1491425762334.jpg
116KB, 1280x720px
Another, much shorter, code sample.
>>
>>60339140
Timeout usually contains relative time. I would probably rename it to "expiration_time"
datetim seems undefined, but hell knows.
DB query is too long, and could be split to multiple lines.
>>
>>60339058
python. every sample of code in the show is from https://github.com/webpy/webpy/blob/master/web/session.py
>>
Code reviews only work when the language isn't a cluster fuck of bizarre idioms.
>>
>>60339287
criticizers in this thread BTFO
>>
>>60339296
> Can't into python
> There is no possibility others can understand this
>>
>>60339124
My bad, urandom takes size, not seed as parameter.
>>
>>60339308
Code review is a helpful process, that increases maintainability. It should not be considered personal.
It depends on the developer, if he accepts it or not
>>
Wtf kind of dumb person names an variable self???
>>
>>60338775
What's the purpose of naming them with "_" before the name?
>>
>>60339454
it indicates its private in python

its not true private though you can still access it, you're just not supposed to
>>
File: 1483605716521.png (84KB, 4000x4000px) Image search: [Google]
1483605716521.png
84KB, 4000x4000px
>>60339438
>>
>>60339438
it's a keyword not variable fuckwit
>>
>>60339480
Sounds dumb. Why doesn't python just build private functions into it's spec?
>>
>>60339521
Well, the double underscore is the true private function, so he already did. I would argue if it was readable.
>>
>>60339438
fucking kill youself, and learn something on the way
>>
File: 1474105901639.jpg (69KB, 800x587px) Image search: [Google]
1474105901639.jpg
69KB, 800x587px
>>60338775
>japanese comments
>_method_name()
6/10 at best.
>>
>>60339053
No different from their music, really. They LOVE throwing in random english words/sentences into their music that only makes sense to a japanese. And programming languages may in many cases use english words, but that doesn't make you a fluent english speaker.
>>
>>60338775
This is why the Japanese can't make a fucking website that doesn't look like it was designed in 1997.
>>
>>60339140
>datetim

Why
>>
File: yukari_hoho.png (15KB, 153x177px) Image search: [Google]
yukari_hoho.png
15KB, 153x177px
>>60338775
>Python
>>
>flat as a board
>mean drunk
>codes in Python
Why would anyone want anything to do with Kobayashi?
>>
>>60338775
>httponly=httponly, secure=secu

I'm not aware of an httponly tag for cookies or secure, only of httpsonly, but either way httponly and secure together make no sense because http is inherently insecure, so enabling a secure flag would make it no longer httponly.
>>
>>60338775
Lmao python
Self self self self self self self self
>>
>>60341744
httpOnly: Cookie is managed by the browser and can't be read or used using Javascript. Especially useful for session cookies.
secure: Cookie is only sent over HTTPS or other encrypted channels, never over bare HTTP.

learn yourself a websec desu
https://developer.mozilla.org/docs/Web/HTTP/Cookies#Secure_and_HttpOnly_cookies
>>
>>60341744
>either way httponly and secure together make no sense

HttpOnly means it cannot be read by JavaScript, making it a good choice as a defense-in-depth mechanism for limiting the impact of e.g., XSS.

It is entirely separate from "Secure" which mandates cookies should only be sent over HTTPs.
>>
>>60338775
Having read >>60339287

The "now" in _generate_session_id is entirely useless.
>>
>>60338775
Why is a detective koding?
>>
>>60341967
thank god you don't have to use ; to end a line though.
>>
>>60341967
You can name the instance parameter whatever you like. "pancake" or "this" is fine, although it violates PEP 8.
>Always use self for the first argument to instance methods.
>Always use cls for the first argument to class methods.
(Java uses even more retarded names like "clazz" here.)
>If a function argument's name clashes with a reserved keyword, it is generally better to append a single trailing underscore rather than use an abbreviation or spelling corruption. Thus class_ is better than clss.
>>
>>60338775
why would anyone else handle session logic that can be handled by a framework?
>>
>>60338775
Indentation is borked. It's inside a class with 2 spaces of indent (it seems), but the methods have 4 spaces (or a tab).
>>
>>60338775
>using os.urandom()

anything like this will render the entire CPU cycle unusable until that bit finishes executing. better to run it on a separate thread
>>
>>60342203
because he got inspired to get into it by karlie
>>
>>60341614
ugly too
>>
>>60341614
>>60343135
Fuck off; Don't talk shit about my kobayashi!
>>
>>60343147
You know she's a lesbian, right?
>>
>>60343176
and?
>>
>>60342904
Python is inherently single threaded anyway, so why should it matter?

In any event, "secrets" or "SystemRandom" from the "random" module should probably be used instead.
>>
>>60342904

You don't use python for optimal runtime.
>>
>>60343210
unless you're a girl, thats the worst waifu.
>>
>>60339058
>Python
No thank you, strong typing is a godsend
>>
>>60339095
It's Python and no it doesn't. You can implement them just by defining variables
A = 0
B = 1
C = 2
etc.
But the language has no explicit support for them.
>>
>>60344038
> I love creating degenerated interfaces for acyclic visitor patterns.
Python doesn't need this workaround
>>
>>60338775
all python code is trash, you can't write good code in it because it straight up wont let you
>>
>>60339140
Cute. Dictionary syntax backed by a database sounds super comfy
>>
File: 1476109552369.png (80KB, 1280x960px) Image search: [Google]
1476109552369.png
80KB, 1280x960px
>>60345628
>because it straight up wont let you
>>
>>60344084
Python has support for enumerated classes in the stdlib. https://docs.python.org/3/library/enum.html
>>
File: checked.jpg (12KB, 248x249px) Image search: [Google]
checked.jpg
12KB, 248x249px
>>60338998
>self.get
>>
this is now a self.get thread

self.get
>>
File: pythoned.png (178KB, 330x319px) Image search: [Google]
pythoned.png
178KB, 330x319px
>>60339480
>not having access modifiers
kek
I'm sorry for you all, pythonists.
Guido can't into proper languages.
>>
>>60339572
Thats not true private either. It invokes python name mangling algorithm. The final method will still be public but will have different name (consisting in adding trivial prefixes and more underscores).
>>
>>60339287
Python looms like that!?!?

No wonder the language sucks so hard.
>>
Enterprise/10

If they really wanted a realistic soul crushing Dev shop place it would have been an Enterprise Java Factory factory.

>>60339287
Nice catch. Props to them for using something real.
>>
>>60339296
/thread
Python is a language for non-professional programmers and it shows in every part.
>>
>>60339521
If that grinds your gear, wait until you meet Pythons JS-tier scoping rules.

see
>>60341015
>>60346887
>>60347193
>>
>>60338775
m8 this is webpy.
Thread posts: 67
Thread images: 9


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