Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
How to write bad codeHow to write bad code
using C# and JavaScriptusing C# and JavaScript
Wekoslav Stefanovski
The Worst thing about SoftwareThe Worst thing about Software
 It can be horribly written
 It can be an unmaintainable me...
Why is Software special?Why is Software special?
 It’s relatively new, and very unstable field to
work in
 It bootstraps...
Why we have so much badWhy we have so much bad
code?code?
1. It works – why change it?
2. I don’t know how to make this
3....
But since there is so much of itBut since there is so much of it
out there, it must be inout there, it must be in
demand?d...
Anti-patternsAnti-patterns
• Something that looks like a good idea
• But it’s not – backfires when used 
• “common respon...
Pattern FetishPattern Fetish
• I have this pattern, where could I use it?
• Heavily dependent on the last blog post the
ar...
Shiny new frameworkShiny new framework
• Code that someone has already written for you
• Highest quality possible
• Soluti...
Apocalypse ReadyApocalypse Ready
• As a developer, you need to be ready for
everything
• Ensure that your code will never ...
• One omnipotent, omnisapient class
• One stop shop for all your needs
• Enables easy location
of methods and code
• Remov...
Object OrgyObject Orgy
 Restricted access to state means you only need
to rely on what the developer thought you
needed.
...
Data BuffetData Buffet
• Eagerly loading all the data you might need
• Actively anticipates the user actions
• Enables for...
Not Invented HereNot Invented Here
• Most libraries are intended for general use
• Some libraries have weird licences (som...
Inner Platform Effect - SoftcodingInner Platform Effect - Softcoding
• When you really, truly need everything to be as
dyn...
Spaghetti codeSpaghetti code
• Structure takes back seat to functionality
• Everything can go everywhere (e.g. SQL
generat...
Any questions?Any questions?
Hopefully you know I’m only joking, right? Right?Hopefully you know I’m only joking, right? R...
Upcoming SlideShare
Loading in …5
×

How to write bad code using C#

967 views

Published on

There has been lots of talk on the importance of writing good and manageable code – code whose inherent beauty bring tears to the eyes of the developer that looks at it. This talk is not like that. This talk will focus on the techniques that are used by millions across the world to bring tears to the eyes of the maintaining developer, as well as a graphic stream of profanities.We will investigate some of the most common anti-patterns and half-measures that occur in real live code, and will marvel at the ingenuity and outright creativity necessary to create ugly messes of unmaintainable code that still manages to work for it’s users.

Published in: Technology
  • Be the first to comment

How to write bad code using C#

  1. 1. How to write bad codeHow to write bad code using C# and JavaScriptusing C# and JavaScript Wekoslav Stefanovski
  2. 2. 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
  3. 3. 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
  4. 4. Why we have so much badWhy we have so much bad code?code? 1. It works – why change it? 2. I don’t know how to make this 3. I know how to make this 4. I don’t have time right now 5. I don’t know what the current code does
  5. 5. But since there is so much of itBut since there is so much of it out there, it must be inout there, it must be in demand?demand? So, how do can we make badSo, how do can we make bad code?code?
  6. 6. 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
  7. 7. 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
  8. 8. 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
  9. 9. 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
  10. 10. • 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
  11. 11. 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
  12. 12. 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
  13. 13. 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
  14. 14. 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
  15. 15. 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
  16. 16. Any questions?Any questions? Hopefully you know I’m only joking, right? Right?Hopefully you know I’m only joking, right? Right?

×