3

First, sorry for my English guys.

Currently this is my first programming job. I am labeled as the most incompetent programmer in my company that's because they measure the performance and productivity of programmer by how fast you can get things done. I'm not really sure if I'm slow or not, because I always test(manual testing) my code before submitting it, and I'm pretty sure that most programmers here don't test their code the way I test mine. I don't do automated test because I admit that the concept is still complex to me. Since our software is not yet use by the user, we don't know which programmer has the most or fewer bugs. And also the system is for internal use only, so we don't have strict deadline. Time to ship is not that important.

We don't have best practices, automated testing, code reviews, and coding standard here in the company, so basically you are on your own, just make the code works and your fine. Almost all of the programmers here are fresh from college. Even me I'm a fresh graduate.

I think the reason why they are fast it's because they do all of the business logic in sql. So Basically they have all the UI code and Sql code in one .aspx file just like the code below

Patial class InvoiceView : Page
{
    protected void button_click(object sender, Eventargs a)
    {
     string sql = "Select * from some blah blah blah";
     DataTable tab = .....some Ado.net code here.
     Gridview.DataSouce = Tab;
     Gridview.DataBind();
    }
}

Before I got my first job(although this is my first job), I don't code like this anymore I usually use a custom object just like the code below.

Public class Invoice
{
     public int InvoiceNo {get;set;}
     Public DateTime PaidDate {get;set;}
     Public List<Item> Items {get;set;}
     public decimal Amount {
     get
        {
         decimal amount = 0;
         foreach(var i in Items)
         {
            amount = amount + i.TotalPrice;
         }
         return amount;
        }
    }
}

after that, I'm going to create a DataMapper class, and I'm pretty sure this is the reason why I'm slow, because I have to manually map the row table to objects and test the datamapper. So basically their is no ORM or micro ORM. Our database don't have referential integrety and tables always change. So I thought ORMs are not ideal for this project.

The person that labeled me as the most slowest is actually a junior programmer just like the rest. He has 2 years experience ahead of us, that's why he is our immediate superior. Sometimes I always think that the reason why he said that is because he is still a junior and no experience when it comes to managing a team of programmers.

I'm confident that I can do all the job they will throw at me.

Here is my question.

  1. Should I use DataTable and shove it to gridview just like the rest of my team do?

  2. When to use DataTable instead of custom objects or domain classes?

  3. Currently I only know two Data Access pattern, ActiveRecord and DataMapper. What do you call the pattern that my team uses?

  4. How can I code faster?

Thanks guys, sorry for my English.

  • If you want faster mapping of SQL queries, use an ORM like Entity Framework. Don't worry about your speed, learn to be good and then get a new job where professionals work. – gbjbaanb Mar 26 '15 at 8:43
  • 1
    It sounds like your team does a lot of "copy-paste" programming. Regardless, I concur with the idea of using an ORM; an ORM might actually improve the referential integrity. – Robert Harvey Mar 26 '15 at 14:03
2

Automated testing

Invest your time in automated testing. It will pay you off very quickly.

The basic idea is that if you do manual testing only, you'll be unable to handle the ever increasing number of tests. It is not unusual for even a relatively small application to have thousands of tests, not counting integration, system, functional, load and other tests. If this application is delivered daily, this means that you'll need to do thousands of tests by hand, every day. If it takes you more than 8 hours to run all of them, you won't have time to do anything else any longer.

Why running those thousands of tests in the first place?

Mostly to avoid regressions. When you write new code, no matter how much you thought about the consequences of the change, it may (and often will) break something else, somewhere else. If the architecture and the design are good, this will happen rarely and will affect only a few mostly related classes. If the architecture and the design are not so good, you can effectively change something in one place, and see features which look completely independent break.

Code

If you're convinced that your code is good and your coworker's code is less good, the time it takes to you to deliver features shouldn't be a concern. Once the product starts to be used by customers, they will report bugs. If your code is easy to maintain and have fewer bugs, your coworkers will spend most of their time correcting bugs, while you, on the other hand, will be delivering features, achieving a better score on the metric used in your company.

It might be (although it's not clear from your question, I don't think it's the case) that your coworker's code is fine, and yours' is over-architected. In this case, indeed, you are spending more time than needed by writing code which is unnecessary. Having your code being reviewed by your colleagues may give you a better image. If through the review, they achieve to simply and reduce it while keeping it maintainable, there is indeed a problem.

Tools

Make sure you know your tools. IDE, static checkers, code generators, whatever. For example, your Invoice class, aside Amount property could have been written automatically by a code generator. This may not make a huge difference for a single class, but if you have dozens of them, containing dozens of properties, code generators may have an impact.

1
  1. Should I use DataTable and shove it to gridview just like the rest of my team do?

Hell no. That's just bad code. It's ok code for very small uncomplicated projects that are unlikely to change and has a database schema that will rarely if ever change. Or for quick one-off-projects. Otherwise that is bad code practice and it will come back and bite you in the ass later.

  1. When to use DataTable instead of custom objects or domain classes?

Never. Or well, as said before. For very small one-off projects. Though even then I prefer to stay as far away from DataTable as possible and use Dapper or Massive or something similiar to not have to write code against DataTable.

  1. Currently I only know two Data Access pattern, ActiveRecord and DataMapper. What do you call the pattern that my team uses?

"Maintenence hell" :)

  1. How can I code faster?

From what you are telling, it's not you who should code faster, its your team who should code slower. Fast coding is good, but correct coding is better. If you code correctly, adhering to best practices and doing automated testing and so on you will get faster in the long run by minimizing maintenence nightmares and having a more stable system that will be easier to change later on. Going fast is good, but not if you go fast and then end up with a system that you cannot add new features to or maintain. Go as fast as possible without cutting corners. With time and experience, you'll find the correct pace where you can deliver correct code fast enough.

  • 1
    There's a lot of opinions here, but not much objective explanation. – Robert Harvey Mar 26 '15 at 13:59
0

I'll go against the grain slightly from the advice of "keep coding good/slow" and "find a new job" that you'll be receiving in the other answers, in case neither of those options are desirable for you.

Here's the sad truth: Sometimes its better to write crappy code that conforms to the team's style than it is to write good code that goes against the grain. However, you will need to spend some time covering your own rear-end and reputation against the inevitable slew of bugs and maintentance issues that will arise when some other junior dev goes and changes the database schema and your apps break.

Your team's style is to have lots of Web Forms apps that each have a ton of sql in button click events and GridView bindings, without a lot of "middle tier" pieces like reusable data classes and structures. This makes it near impossible to do Unit Testing, however that does not mean you cannot test at all. What you will need to do is focus on how to do coded UI Integration tests for your own work.

I HIGHLY recommend the Canopy UI Testing Nuget package (PM> Install-Package canopy). Its an F#-based UI testing tool, but don't let the F# scare you off, its very easy to learn the basics of how to wire up tests, and it uses CSS-style selectors, which you probably already know (or can learn easily).

If I were you, I would perform this type of workflow for when you need to code a new (sloppy) Web Forms app fast:

1) Go ahead and wire up your Web Forms app as fast as you can, using the dirty sql-in-button-event style that your colleges use. Say what you will about it, it IS fast/easy to write apps with that style (long-term maintenance is a nightmare, but that's the culture your team has selected!)

2) Write a SQL script to populate your test database with a set of known values

3) Write the Canopy/Other UI tests to run your app according to the requirements (put in value X on page Y and display result Z). These will verify any computed values that get output to the screen, as well as ensuring that you don't get any Yellow Screens of Death. You could also do things like have hidden 'test' pages that do nothing but check the database tables for the expected schemas and throw errors if they change enough to break your app.

4) If necessary, write a final sql script to check any database values not checked by your UI tests.

Now, you can run these tests periodically, and if there's any errors that come through because Steve the Intern changed a table's schema without telling the team, then its CRYSTAL CLEAR that he did it, and its not the fault of your web app. In the environment you are in, covering your own ass is going to be critically important. The team already views you as slow, and its going to take you a LONG time to change their opinion, so you'll need to get coding fast before you can earn their respect/trust.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.