Halit's blog

By Halit, history, 6 months ago, In English,

Hello!

I have a question. I see some codes (some tourist codes) which includes Classes. Is it Useful or waste of time in Competitive Programming?

 
 
 
 
  • Vote: I like it
  • +21
  • Vote: I do not like it

»
6 months ago, # |
  Vote: I like it +12 Vote: I do not like it

You should write classes before the contest starts, is bad to write at contest because you lose time.

»
6 months ago, # |
  Vote: I like it +13 Vote: I do not like it

I usually like code in my reference in classes because it's usually easier to use/create more than one object. If you have a complicated parsing/dp on syntax tree you can use polymorphism and code is actually way nicer (looking at Petr's solution of the parser problem in 2019 ICPC WF)

  • »
    »
    6 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    How can I found it?

    • »
      »
      »
      6 months ago, # ^ |
        Vote: I like it +10 Vote: I do not like it

      Look for 2019 WF petr in youtube and it's around 3h in

»
6 months ago, # |
  Vote: I like it +38 Vote: I do not like it

OOP is a meme, and a shitty one to boot, like "thing I don't like" comic edits. Code design should be whatever works best for you and your collaborators, not a cursed mass of objects for no practical purpose.

Classes don't make your code OOP. Most of the time, non-library code with classes could be replaced by uglier code in pure C without too much effort. And yes, classes are useful. When you're starting to think about OOP things like multiple inheritance in the code you're writing in-contest, it's time to turn 360° and walk away.