loading words...

May 29, 2019 21:48:28

Complexity: Code

by @craigpetterson PATRON | 207 words | 192πŸ”₯ | 193πŸ’Œ

Craig Petterson

Current day streak: 192πŸ”₯
Total posts: 193πŸ’Œ
Total words: 51456 (205 pages πŸ“„)

Oof, talking about code complexity. What the hell have I got myself into?

I want to pad this section out with a couple of code examples, maybe even just one.

Principles

Occam's Razor: effectively, the simplest solution is usually correct.

KISS: Keep it simple, stupid.

Naming

In my day to day development, I try to remove any ambiguity from anything I write.

We have several classes that are a nightmare to type out:

  • SBTLI
  • PA
  • BPF
  • (I)BT
    - This one in particular is my favourite, because in bt is backtrace in byebug
  • (B/S/P)FI
  • GGA

Oh, interesting acronyms… No… what the hell do they mean?

If you gave this to somebody they wouldn't understand any of it and why would they?

It's an understandable mistake though. Naming is hard. Typing out long names is frustrating.

If you can get this right. Give me a shout.

CRUD

I'm a firm believer in CRUD controllers. These are controllers that adhere to the 7 actions that are needed to do everything.

If you're adding more actions over these 7, then you have just made a CRUD actions that should be in a different controller.

The perfect controller action would be (nearly) empty.


That's 200 words, but I need to elaborate on these…

From Craig Petterson's collection:

contact: email - twitter / Terms / Privacy