• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:59
CEST 23:59
KST 06:59
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12[ASL20] Ro24 Preview Pt2: Take-Off7[ASL20] Ro24 Preview Pt1: Runway13
Community News
SC4ALL $6,000 Open LAN in Philadelphia7Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29LiuLi Cup - September 2025 Tournaments3Weekly Cups (August 25-31): Clem's Last Straw?39Weekly Cups (Aug 18-24): herO dethrones MaxPax6
StarCraft 2
General
Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues #1: Maru - Greatest Players of All Time Team Liquid Map Contest #21 - Presented by Monster Energy Classic Games #3: Rogue vs Serral at BlizzCon What happened to Singapore/Brazil servers?
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series WardiTV TL Team Map Contest #5 Tournaments Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
Pros React To: SoulKey's 5-Peat Challenge BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion ASL20 General Discussion BSL Team Wars - Bonyth, Dewalt, Hawk & Sziky teams
Tourneys
[IPSL] ISPL Season 1 Winter Qualis and Info! Is there English video for group selection for ASL [ASL20] Ro16 Group B [ASL20] Ro16 Group A
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Nintendo Switch Thread Path of Exile General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
Canadian Politics Mega-thread US Politics Mega-thread Russo-Ukrainian War Thread The Big Programming Thread Things Aren’t Peaceful in Palestine
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1291 users

#TODO: Find suitable ransom to nego new end points - Page 2

Blogs > Chef
Post a Reply
Prev 1 2 All
Fecalfeast
Profile Joined January 2010
Canada11355 Posts
November 25 2015 03:23 GMT
#21
On November 24 2015 11:36 patrick321 wrote:
The OP's post was clever but fecalfeast's was art. The form perfectly embellished the content. And his topical name was the cherry on top of the cow pie.

Critiquing his code here is like stopping a singer to correct his lyrics.

I actually appreciate the advice, I often run into annoying problems that are often just fixed by being more organized. Besides, if his OP is a shitpost, my post is literally regurgitated shit.
On November 24 2015 23:31 Chef wrote:
Show nested quote +
On November 24 2015 11:15 Fecalfeast wrote:
I was writing the comments to explain to me what I wanted to program to do. I lack organization and writing things down before I can articulate them in code keeps me on track.

What does 'in scope' mean? I'm fairly green at programming and just make tools that I can't find with a simple google search.

Are you saying it would be better to have a separate method for finding food, then feed that variable through chew's parameter brackets?

Sure, it's not problem. I like to write methods I wish existed when thinking about the top level logic of my code, and then write the methods.

My bad about the scope, your methods are all in the global scope so they are accessible to one another.

ex

2.1.3 :001 > def bear; puts 'bear'; end
=> :bear
2.1.3 :002 > def kuma; puts bear; end
=> :kuma
2.1.3 :003 > kuma
bear

In larger applications, you have to throw things into classes and modules, so that you can avoid naming collisions by polluting the global scope (you can google javascript global scope for a typical explanation).

If for example you had defined method A within method B, you wouldn't be able to access method A outside method B. Similarly, if you define methods within a class, you can access them anywhere within the class, but outside the class you have to call Class.method (or if you have an instance of the class, instance.method).

I'm just saying your method chew does not describe accurately enough what it does, which is find food and digest it and vomit it out. So when someone calls chew they will get the unexpected result of vomit. Really your method would be accurately called find_food_eat_it_and_vomit_it_out which is a method that seems to have a lot of responsibilities. If I wrote such a method, it would have calls to three other methods, find_food eat_food (which has chew_food and swallow_food methods) vomit_food. This way the code is more reusable, the stack trace will be easier to read, and if you need to update one of them, all your methods that use them will be updates simultaneously, instead of you having to update the same code in multiple places.

Even if all you use code for is one off scripts for yourself, it might help you to build a library of methods you often need to use (which you could do a very simple require to have accessible in all your scripts, saving you some copy / pasting). Naming those methods logically will help you to remember without referencing them.

So separating them into

def find_food()
stuff
end
def chew()
differentStuff
end
def swallow_digest()
otherStuff
end
def vomit()
endResult
end
def indigestion()
find_food()
while food
chew()
swallow_digest()
vomit()
puts "I'm hungry again"
end
indigestion()

would be better because it's easier to tell where something goes wrong when something goes wrong?
ModeratorINFLATE YOUR POST COUNT; PLAY TL MAFIA
YourGoodFriend
Profile Blog Joined June 2010
United States2197 Posts
November 25 2015 20:21 GMT
#22
On November 25 2015 12:23 Fecalfeast wrote:
Show nested quote +
On November 24 2015 11:36 patrick321 wrote:
The OP's post was clever but fecalfeast's was art. The form perfectly embellished the content. And his topical name was the cherry on top of the cow pie.

Critiquing his code here is like stopping a singer to correct his lyrics.

I actually appreciate the advice, I often run into annoying problems that are often just fixed by being more organized. Besides, if his OP is a shitpost, my post is literally regurgitated shit.
Show nested quote +
On November 24 2015 23:31 Chef wrote:
On November 24 2015 11:15 Fecalfeast wrote:
I was writing the comments to explain to me what I wanted to program to do. I lack organization and writing things down before I can articulate them in code keeps me on track.

What does 'in scope' mean? I'm fairly green at programming and just make tools that I can't find with a simple google search.

Are you saying it would be better to have a separate method for finding food, then feed that variable through chew's parameter brackets?

Sure, it's not problem. I like to write methods I wish existed when thinking about the top level logic of my code, and then write the methods.

My bad about the scope, your methods are all in the global scope so they are accessible to one another.

ex

2.1.3 :001 > def bear; puts 'bear'; end
=> :bear
2.1.3 :002 > def kuma; puts bear; end
=> :kuma
2.1.3 :003 > kuma
bear

In larger applications, you have to throw things into classes and modules, so that you can avoid naming collisions by polluting the global scope (you can google javascript global scope for a typical explanation).

If for example you had defined method A within method B, you wouldn't be able to access method A outside method B. Similarly, if you define methods within a class, you can access them anywhere within the class, but outside the class you have to call Class.method (or if you have an instance of the class, instance.method).

I'm just saying your method chew does not describe accurately enough what it does, which is find food and digest it and vomit it out. So when someone calls chew they will get the unexpected result of vomit. Really your method would be accurately called find_food_eat_it_and_vomit_it_out which is a method that seems to have a lot of responsibilities. If I wrote such a method, it would have calls to three other methods, find_food eat_food (which has chew_food and swallow_food methods) vomit_food. This way the code is more reusable, the stack trace will be easier to read, and if you need to update one of them, all your methods that use them will be updates simultaneously, instead of you having to update the same code in multiple places.

Even if all you use code for is one off scripts for yourself, it might help you to build a library of methods you often need to use (which you could do a very simple require to have accessible in all your scripts, saving you some copy / pasting). Naming those methods logically will help you to remember without referencing them.

So separating them into

def find_food()
stuff
end
def chew()
differentStuff
end
def swallow_digest()
otherStuff
end
def vomit()
endResult
end
def indigestion()
find_food()
while food
chew()
swallow_digest()
vomit()
puts "I'm hungry again"
end
indigestion()

would be better because it's easier to tell where something goes wrong when something goes wrong?



Its part of the SOLID principles, single responsibility for methods/functions/class each method should only do one thing (ie. swallow and chew are two different things)

This allows for ease of testing and future proofing because if you need to change how chewing works it shouldnt impact (as much) anything else. Also if you have tests written then after you make a change you rerun your tests and it tells you either where there are issues or that your change is fine. If you have a giant method then if your test fails you dont really know what failed as it was just something in that method, where as if it is broken out you can tell "oh the swallow part didnt work, lets go fix it"
anonymous is the most famous author that anyone can be
Silvanel
Profile Blog Joined March 2003
Poland4731 Posts
November 29 2015 09:39 GMT
#23
try:
Chef is "Funny"
print(" Best post ever 5/5!! ")

except ValueError:
print("I will probably get banned for it but i have to say...........")
sys.exit()
Pathetic Greta hater.
AKnopf
Profile Blog Joined March 2011
Germany259 Posts
December 06 2015 11:16 GMT
#24
+1 for require_relative


Whoops, thought we were on Github
The world - its a funny place
Prev 1 2 All
Please log in or register to reply.
Live Events Refresh
BSL Team Wars
19:00
Playoff - 4th vs 3rd
Team Bonyth vs Team Sziky
ZZZero.O82
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
JuggernautJason127
Nathanias 64
Lillekanin 11
StarCraft: Brood War
ZZZero.O 82
sSak 30
NaDa 14
Dota 2
NeuroSwarm123
LuMiX1
Counter-Strike
fl0m1579
Stewie2K521
Heroes of the Storm
Liquid`Hasu552
Other Games
Grubby3741
FrodaN2523
ToD415
KnowMe185
Sick176
SortOf125
Organizations
Other Games
BasetradeTV42
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• RyuSc2 42
• musti20045 41
• StrangeGG 37
• Sammyuel 7
• IndyKCrew
• AfreecaTV YouTube
• sooper7s
• intothetv
• Kozan
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• HerbMon 23
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota22982
League of Legends
• Doublelift5158
Other Games
• imaqtpie1191
• Scarra985
Upcoming Events
Afreeca Starleague
12h 1m
Snow vs Sharp
Jaedong vs Mini
Wardi Open
13h 1m
OSC
1d 2h
Sparkling Tuna Cup
1d 12h
Afreeca Starleague
1d 12h
Light vs Speed
Larva vs Soma
PiGosaur Monday
2 days
LiuLi Cup
2 days
RSL Revival
3 days
Maru vs Reynor
Cure vs TriGGeR
The PondCast
3 days
RSL Revival
4 days
Zoun vs Classic
[ Show More ]
Korean StarCraft League
5 days
RSL Revival
5 days
[BSL 2025] Weekly
5 days
BSL Team Wars
5 days
RSL Revival
6 days
Online Event
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
SEL Season 2 Championship
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL Polish World Championship 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
SC4ALL: StarCraft II
EC S1
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.