Horrible code coping - 4 ... ideas.

by Jesse 8. February 2010 20:51

I've heard about those projects people end up on and I'm sure you've heard of them too. Everything is done in the most complicated way known to man never to be understood again.  There are odd debugging like statements with logic in them that might be useful ... strange, undescriptive (cryptic?) variable names to which you have no idea what they might do and don't forget your god classes -- those are a must!  So before we go down this pile of atrocities against the human race, let's look at some examples.  Sadly, these are real world examples.

                If thisRow("FormField").ToString().Trim() = "check12a" Then
                    strValue = strValue
                End If

                If thisRow("ExhibitTest").ToString() <> "" Then bDoExhibit = CType(RetrieveValue(thisRow("ExhibitTest").ToString(), "E", "", docInput, xpathNav), Boolean)

Yes, I have seen the strValue = strValue in the real world.  It's sad and seriously calls into question "WHAT WERE YOU THINKING?".  I can't ask that, those people are long gone.  There's no documentation, the code isn't very readable and to boot -- the database takes a while to save stuff (so checking on saved items might take 2 seconds or 15+).  So as a better developer, what do you do? More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Subsonic, Oracle, and fighting the fail

by Jesse 8. February 2010 20:25

If you've seen my twitter feed lately (if you haven't, I don't blame you), I've been complaining a LOT about datasets, so I went looking to an old friend, subsonic.  Why subsonic?  Because it works.  It works well.  It works with just about every database I've EVER come across.  In my opinion, its a true abstraction layer between data and service to which it fits nicely in between because it works with so much stuff.

As of late, I've been taking Jon's suggestion of highly-specialized interfaces -- GetService, UpdateService, DeleteService and CreateService to make up a one stop shop to make this work.  I know he didn't invent this idea, but he brought it to my attention in a very indirect way.  Anyway, I've found this to be a great idea, but it's amazingly difficult to imbue on certain data layers, such as with datasets.  I WAS able to use a IGetService for it, as such...

public class GetService<T> : IGetService<T> where T : class, IObjectToEntity, IDataTableEntity
{
    
private DataTable _table;
    
private SuperAdapter _adapter;
    
private OracleDataAdapter _dbAdapter;
    
private IQueryable<T> _entityList;

     public GetService(DataTable table)
     {
          _table = table;
          _adapter =
new SuperAdapter();
          _dbAdapter = _adapter.AdapterFactory(_table.TableName);
          _dbAdapter.Fill(_table);
          _entityList = _table.Rows.ToEntityListOf<T>().AsQueryable();
     }

}

More...

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , ,

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Like the description says, at my core, I'm a scientist and engineer.  I came from humble beginnings on a 486DX2 Packard Hell playing doom2 on IPX to in a small time retail shop and got into hardware (ISO layers FTW!) and it was all downhill from there.  I'm infinitely curious about almost everything and always wanting to know.

According to personality tests (real ones) I classify under "Rational" more specifically, a Fieldmarshal.  I think there's something to that.

Some of the stuff I'm currently into/researching...

Sitefinity

Ninject

Subsonic 

Currently working on ...
i did the hundred


and some extra stuff

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's, their brother, their dog, cat, ferret nor gold fish's view in anyway.  At all.  Ever.

© Copyright 2007-2009