Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 60909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:14:09+00:00 2026-05-10T18:14:09+00:00

Recently, I made a post about the developers I’m working with not using try

  • 0

Recently, I made a post about the developers I’m working with not using try catch blocks properly, and unfortuantely using try… catch blocks in critical situations and ignoring the exception error all together. causing me major heart ache. Here is an example of one of the several thousand sections of code that they did this (some code left out that doesn’t particuarly matter:

public void AddLocations(BOLocation objBllLocations) {     try     {         dbManager.Open();         if (objBllLocations.StateID != 0)         {              // about 20 Paramters added to dbManager here         }         else         {            // about 19 Paramters added here         }         dbManager.ExecuteNonQuery(CommandType.StoredProcedure, 'ULOCATIONS.AddLocations');     }     catch (Exception ex)     {     }     finally     {         dbManager.Dispose();     } } 

This is absolutely discusting, in my eyes, and does not notify the user in case some potential problem occurred. I know many people say that OOP is evil, and that adding multiple layers adds to the number of lines of code and to the complexity of the program, leading to possible issues with code maintainence. Much of my programming background, I personally, have taken almost the same approach in this area. Below I have listed out a basic structure of the way I normally code in such a situation, and I’ve been doing this accross many languages in my career, but this particular code is in C#. But the code below is a good basic idea of how I use the Objects, it seems to work for me, but since this is a good source of some fairly inteligent programming mines, I’d like to know If I should re-evaluate this technique that I’ve used for so many years. Mainly, because, in the next few weeks, i’m going to be plunging into the not so good code from the outsourced developers and modifying huge sections of code. i’d like to do it as well as possible. sorry for the long code reference.

// ******************************************************************************************* /// <summary> /// Summary description for BaseBusinessObject /// </summary> /// <remarks> /// Base Class allowing me to do basic function on a Busines Object /// </remarks> public class BaseBusinessObject : Object, System.Runtime.Serialization.ISerializable {     public enum DBCode     {   DBUnknownError,         DBNotSaved,         DBOK     }      // private fields, public properties     public int m_id = -1;     public int ID { get { return m_id; } set { m_id = value; } }     private int m_errorCode = 0;     public int ErrorCode { get { return m_errorCode; } set { m_errorCode = value; } }     private string m_errorMsg = '';     public string ErrorMessage { get { return m_errorMsg; } set { m_errorMsg = value; } }     private Exception m_LastException = null;     public Exception LastException { get { return m_LastException; } set { m_LastException = value;} }      //Constructors     public BaseBusinessObject()     {         Initialize();     }     public BaseBusinessObject(int iID)     {         Initialize();         FillByID(iID);     }     // methods     protected void Initialize()     {         Clear();         Object_OnInit();         // Other Initializable code here     }     public void ClearErrors()     {         m_errorCode  = 0; m_errorMsg = ''; m_LastException = null;     }      void System.Runtime.Serialization.ISerializable.GetObjectData(          System.Runtime.Serialization.SerializationInfo info,          System.Runtime.Serialization.StreamingContext context)     {       //Serialization code for Object must be implemented here     }     // overrideable methods     protected virtual void Object_OnInit()          {         // User can override to add additional initialization stuff.      }     public virtual BaseBusinessObject FillByID(int iID)     {         throw new NotImplementedException('method FillByID Must be implemented');     }     public virtual void Clear()     {         throw new NotImplementedException('method Clear Must be implemented');     }     public virtual DBCode Save()     {         throw new NotImplementedException('method Save Must be implemented');     } } // ******************************************************************************************* /// <summary> /// Example Class that might be based off of a Base Business Object /// </summary> /// <remarks> /// Class for holding all the information about a Customer /// </remarks> public class BLLCustomer : BaseBusinessObject {     // ***************************************     // put field members here other than the ID     private string m_name = '';     public string Name { get { return m_name; } set { m_name = value; } }     public override void Clear()     {         m_id = -1;         m_name = '';     }     public override BaseBusinessObject FillByID(int iID)     {         Clear();         try         {             // usually accessing a DataLayerObject,              //to select a database record         }         catch (Exception Ex)         {             Clear();             LastException = Ex;             // I can have many different exception, this is usually an enum             ErrorCode = 3;             ErrorMessage = 'Customer couldn't be loaded';         }         return this;     }     public override DBCode Save()     {         DBCode ret = DBCode.DBUnknownError;         try         {             // usually accessing a DataLayerObject,              //to save a database record             ret = DBCode.DBOK;         }         catch (Exception Ex)         {             LastException = Ex;             // I can have many different exception, this is usually an enum             // i do not usually use just a General Exeption             ErrorCode = 3;             ErrorMessage = 'some really weird error happened, customer not saved';             ret = DBCode.DBNotSaved;         }         return ret;     } } // ******************************************************************************************* // Example of how it's used on an asp page..      protected void Page_Load(object sender, EventArgs e)     {         // Simplifying this a bit, normally, I'd use something like,          // using some sort of static 'factory' method         // BaseObject.NewBusinessObject(typeof(BLLCustomer)).FillByID(34);         BLLCustomer cust = ((BLLCustomer)new BLLCustomer()).FillByID(34);         if (cust.ErrorCode != 0)         {             // There was an error.. Error message is in              //cust.ErrorMessage             // some sort of internal error code is in             //cust.ErrorCode              // Give the users some sort of message through and asp:Label..              // probably based off of cust.ErrorMessage             //log can be handled in the data, business layer... or whatever             lab.ErrorText = cust.ErrorMessage;         }         else         {             // continue using the object, to fill in text boxes,              // literals or whatever.              this.labID = cust.ID.toString();             this.labCompName = cust.Name;         }     } 

Bottom line, my question is, Am I over complicating things with the muliple layers, and the inherited classes or is my old concept illustrated still working good and stable? Is there a better way now a days to accomplish these things? Should I go to just making straight SQL calls from the asp.net page code behind pages as fellow work associate developer suggested (though that last solution makes me feel icky), instead of going through a business object, and data layer (data layer not shown, but basically holds all the stored proc calls). Yeah, another developer did ask me why i go through the effort of layering things, when you can just type what you need straight in a *.aspx.cs code behind page, and then I can have the joys of over 1k lines of code behind. What is some advice here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T18:14:09+00:00Added an answer on May 10, 2026 at 6:14 pm

    Have you considered using an ORM like NHibernate? There’s no point in re-inventing the wheel.

    To me this is a code smell:

    BLLCustomer cust = ((BLLCustomer)new BLLCustomer()).FillByID(34); 

    Too many brackets!

    I’ve found that using the active record pattern in a language like C# always ends in tears because it’s hard(er) to unit test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You can manipulate files/folders from the IDE! Just click the… May 11, 2026 at 10:40 am
  • added an answer a) Divide the value of your timer property into minutes… May 11, 2026 at 10:40 am
  • added an answer Your goal, to identify the differing parameters for the different… May 11, 2026 at 10:40 am

Related Questions

Recently, I made a post about the developers I'm working with not using try
Recently I made a bunch of changes to my local svn config file. Mainly
Recently I've been designing a Thread class library, I've made a Thread abstract class
I'm using boost for several C++ projects. I recently made a upgrade (1.33.1 to
Let me set the stage here. I'm a very junior developer who's recently made
I have recently reinstalled MacOSX, and at some point (without realizing it) I made
Recently I have discovered that my release executable (made with msvc++ express 2008) becomes
Recently, I started changing some of our applications to support MS SQL Server as
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently, I read an article entitled SATA vs. SCSI reliability . It mostly discusses

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.