16
How to write bad code How to write bad code using C# and JavaScript using C# and JavaScript Wekoslav Stefanovski

How to write bad code using C#

Embed Size (px)

Citation preview

Page 1: How to write bad code using C#

How to write bad code How to write bad code using C# and JavaScriptusing C# and JavaScript

Wekoslav Stefanovski

Page 2: How to write bad code using C#

The Worst thing about SoftwareThe Worst thing about Software It can be horribly written It can be an unmaintainable mess It can be completely instable and untestable It can be absurdly undocumented But it can still work very well

There is no connection between the way the code of a product is made and the end product

Yet, the code IS the product

Page 3: How to write bad code using C#

Why is Software special?Why is Software special? It’s relatively new, and very unstable field to

work in It bootstraps itself Not only the standards, but even the definitions

are changing all the time It’s changeable at every step of the process It’s changing at every step of the process Lots of folks are getting left behind

Page 4: How to write bad code using C#

Why we have so much bad Why we have so much bad code?code?

1. It works – why change it?2. I don’t know how to make this3. I know how to make this4. I don’t have time right now5. I don’t know what the current code does

Page 5: How to write bad code using C#

But since there is so much of it But since there is so much of it out there, it must be in out there, it must be in demand?demand?

So, how do can we make bad So, how do can we make bad code?code?

Page 6: How to write bad code using C#

Anti-patternsAnti-patterns• Something that looks like a good idea• But it’s not – backfires when used • “common response to a recurring problem that

is ineffective and highly counterproductive”

• Analysis Paralysis / Design by committee• Cargo-cult programming• Vendor lock-in• Mushroom management• Lava flow development

Page 7: How to write bad code using C#

Pattern FetishPattern Fetish• I have this pattern, where could I use it?• Heavily dependent on the last blog post the

architect had read• Patterns are good, working and proven practices• More patterns you use, the gooder the code

gets

Page 8: How to write bad code using C#

Shiny new frameworkShiny new framework• Code that someone has already written for you• Highest quality possible• Solution to most of the problems• Only issue – change your other problems to fit

the framework

Page 9: How to write bad code using C#

Apocalypse ReadyApocalypse Ready• As a developer, you need to be ready for

everything• Ensure that your code will never ever fail, under

any circumstances• Efficiently mitigates Murphy’s law

Page 10: How to write bad code using C#

• One omnipotent, omnisapient class• One stop shop for all your needs• Enables easy location

of methods and code• Removes all circular dependency issues

The God ObjectThe God Object

Page 11: How to write bad code using C#

Object OrgyObject Orgy Restricted access to state means you only need

to rely on what the developer thought you needed.

As a user you don’t need contracts, you need function.

Interactions cannot be predicted in advance

Page 12: How to write bad code using C#

Data BuffetData Buffet• Eagerly loading all the data you might need• Actively anticipates the user actions• Enables forward-thinking• Easy access once the loading is done• Ensures data availability and consistency

Page 13: How to write bad code using C#

Not Invented HereNot Invented Here• Most libraries are intended for general use• Some libraries have weird licences (something

called open source???)• Your project has some specifics that are not

covered• Let’s face it – you could probably do better

Page 14: How to write bad code using C#

Inner Platform Effect - SoftcodingInner Platform Effect - Softcoding• When you really, truly need everything to be as

dynamic as possible• Why not give the power to decide what is what

to the user• Everything is configurable, but it can have a somewhat steep learning curve

Page 15: How to write bad code using C#

Spaghetti codeSpaghetti code• Structure takes back seat to functionality• Everything can go everywhere (e.g. SQL

generated in Javascript)• Copy / pasta virtuosos• Also known as Big Ball of Mud• Alternative to:• Ravioli code• Lasagna code

Page 16: How to write bad code using C#

Any questions?Any questions?

Hopefully you know I’m only joking, right? Right?Hopefully you know I’m only joking, right? Right?