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 8186921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:23:16+00:00 2026-06-07T02:23:16+00:00

I was reading Robert Rossney’s entry on "What’s the most unsound program you’ve had

  • 0

I was reading Robert Rossney’s entry on "What’s the most unsound program you’ve had to maintain?" found at: (What's the most unsound program you've had to maintain?) when I realized that I had inadvertently developed a near-identical application!
The app consists of an HTTPListener object that grabs incoming POST requests. Based on the information in the header, I pass the body of the request to SQL Server to perform the appropriate transaction.
The requests look like:

<InvoiceCreate Control="389>
  <Invoice>
    <CustomerNumber>5555</CustomerNumber>
    <Total>300.00</Total>
    <RushOrder>1</RushOrder>
  </Invoice>
</InvoiceCreate>

Once it’s received by the HTTPListener object, I perform the required INSERT to the Invoice table using SQL Server’s built-in XML handling functionality via a stored procedure:

  INSERT INTO Invoice (InvoiceNumber, CustomerNumber, Total, RushOrder)
  SELECT @NEW_INVOICE_NUMBER,  
         @XML.value('(InvoiceCreate/Invoice/CustomerNumber)[1]', 'varchar(10)'),
         @XML.value('(InvoiceCreate/Invoice/Total)[1]', 'varchar(10)'),
         @XML.value('(InvoiceCreate/Invoice/Total)[1]', 'varchar(10)')  

I then use another SELECT statement in the same stored procedure to return the value of the new Invoice Number that was inserted into the Invoices table:

SELECT @NEW_INVOICE_NUMBER FOR XML PATH 'InvoiceCreateAck'  

I then read the generated XML using a SQL data reader object in C# and use it as the response of the HTTPListener object.

My issue is, I’m noticing that Robert is indeed correct. All of my application logic exists inside the stored procedure, so I find myself having to do a lot of error-checking (i.e. validating the customer number and invoicenumber values) inside the stored procedure.

I’m still a midlevel developer, and as such, am looking to improve. Given the original post, and my current architecture, what could I have done differently to improve the application? Are there any patterns or best practices that I could refer to? What approach would you have taken? I’m open to any and all criticism, as I’d like to do my part to reduce the amount of "unsound programming" in the world.

  • 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. Editorial Team
    Editorial Team
    2026-06-07T02:23:18+00:00Added an answer on June 7, 2026 at 2:23 am

    Not sure about specific patterns, but you need to define your layers and stick to it. I’m using layer very loosely here. You have one layer which needs to parse XML. You have one layer which reads a HTTP request. You have one layer which does data access. If you’re using C#, these are likely 3 separate classes.

    I would not do it in the stored procedure. From my experience, doing this stuff makes it almost be a complete rewrite if you change databases. Testing is really difficult too.

    For your data access, you could still use your stored procedure. I personally would just write simple insert statements using C#. I would just strive to keep any business logic out of the stored procedure. Keep any business logic, parsing in C# as this will be much easier to port later.

    Good luck!

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

Sidebar

Related Questions

I was reading Robert Martin's Clean Code and in that he mentions about the
Reading Apple documentation i found that UIEventTypeMotion is useful only to intercept Shake. It
Reading through the CKEditor documentation , I see that they have an option to
Reading this site, I've found this : [The] line private static final Foo INSTANCE
I am reading the Foundations of F# by Robert pickering. When I try to
I am reading Algorithms book written by Robert Sedwick. Note: s is source and
Reading the code of many javascript libraries, I see that many developers use to
I am reading about network flow algorithms in Robert Sedwicks book on Graph algorithms.
I am currently reading 'Linux Kernel Development' by Robert Love and I do not
Reading the documentation at http://jersey.java.net/nonav/documentation/latest/client-api.html#d4e704 makes me think that ClientFilter s are processed in

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.