Showing posts with label Development. Show all posts
Showing posts with label Development. Show all posts

Tuesday, August 09, 2011

Fluent notation in PL/SQL

I am a big fan of the Fluent notation that has been gaining popularity in the .NET world. I decided to do an experiment to see if I can get PL/SQL to have something similar.

I managed to make this work:

declare
  ftp fluent_ftp := fluent_ftp();
begin
  ftp.run(
    ftp.for_country('UG',
      ftp.for_period('2011', '01', '01', ftp)
    )
  );
end;

To enable this type of syntax I had to create a custom type in PL/SQL first.

CREATE OR REPLACE TYPE schema.fluent_ftp AS OBJECT
(
    country_cd   VARCHAR2(2),
    fin_year_cd  VARCHAR2(4),
    fin_month_cd VARCHAR2(4),
    fin_day_cd   VARCHAR2(4),
    CONSTRUCTOR FUNCTION fluent_ftp RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION fluent_ftp
    (
        a_fin_year_cd  VARCHAR2,
        a_fin_month_cd VARCHAR2,
        a_fin_day_cd   VARCHAR2,
        a_country_cd   VARCHAR2
    ) RETURN SELF AS RESULT,

Internally the new type just calls the existing API so no changes are needed on the underlying API at all.

MEMBER PROCEDURE run(a_fluent_ftp fluent_ftp) IS
    BEGIN
        schema.calculate_ftp.run(a_country_cd   => a_fluent_ftp.country_cd,
                                         a_system_code  => '',
                                         a_fin_year_cd  => a_fluent_ftp.fin_year_cd,
                                         a_fin_month_cd => a_fluent_ftp.fin_month_cd,
                                         a_fin_day_cd   => a_fluent_ftp.fin_day_cd);
    EXCEPTION
        WHEN OTHERS THEN
            RAISE;
        
    END run;

So that is how you can mimic the Fluent notation that the .NET community is enjoying currently on products like Fluent NHibernate and others.

Wednesday, March 30, 2011

Oracle 11gR2 on Solaris


Oracle just ran some benchmarks on their new integrated enterprise platform. Since Oracle bought Sun, they now own some of the best hardware around.

According to this article the new Oracle Solaris (RIP Sun Solaris) together with Oracle 11g R2 is lightning fast. Oracle Benchmark


Tuesday, November 09, 2010

Delphi logging by Exception

I had to help a friend out the other day. He is taking over some Delphi application from someone. That someone decided that the Delphi application is too much work. Now this friend of mine warned me that the code was not very good but I did not expect this piece of beautiful code. Beautiful as in, "What the Hell was this guy thinking".

So we start off with this piece of code

procedure TfrmMain.FormCreate(Sender: TObject);
var
 status         : integer ;
 sc_no          : integer ;
 tmpstr         : string;
 cnt            : integer ;
 comms_protocol : integer ;
begin
  Application.OnException := HandleException;
  ...
end;

So this is not bad, we just register on the top level exception handler in the form's constructor. This event handler code looks like this

procedure TfrmMain.HandleException(Sender: TObject; E: Exception);
var
  filename: string;
  logfile : textfile;
begin
  filename := changefileext(application.exename,'.log');
  assignfile(logfile,filename);
  if fileexists (filename) then
    append(logfile)
  else
    rewrite(logfile);
  writeln(logfile,datetimetostr (now)+':'+e.message);
  if cb_debug.checked then
    application.showexception(e);
  closefile(logfile);
end;

Now in this section I would have liked more begin;end; blocks but some people like to make reading code difficult so not too big a problem. Essentially this code just logs the error to a file. So still not bad.

And then the "What the Hell" moment

try
  raise Exception.create('Program Started');
finally
end;

So this guys wants to log that the application started. Instead of refactoring the log procedure to support program logging he just raises an Exception and does nothing with it. Even worse, in Delphi debug mode, Delphi would stop by default, so now you have to switch off the break on exception option in Delphi just to run his application.

So there you have it, how to log messages by using exceptions in an application and please do not try this at home, this guy was a trained professional*

* A trained professional idiot that is.

Tuesday, September 21, 2010

PC Upgrade 2010, Part 2




I eventually got all my parts and upgraded the PC. It was not without its own set of drama. The first problem I encountered was with my memory. I bought 4 x 2Gb OCZ Gold DDR3 1333MHz memory. After I installed Windows, I could only use 4Gb, the other 4Gb was 'reserved'. Three hours later I found a post on the OCZ forum suggesting that my BIOS detected my DRAM settings wrong and they were right. I manually had to set my DRAM settings in the BIOS, but at least that worked.

i7 Stock Cooler
I then decided to run memtest86+ just in case, and the horror! I had errors in test number 8 in memtest86+. I took out all my DIMMS and reinserted them again, ran memtest86+ and no errors, and just to be sure I ran 5 passes of the tests and another 2 passes the next day.
Cooler Master H212+
My next challenge was heat. The i7 870 with its stock cooler was not good enough. The i7 under load went up to 90C which is not good. Idle temp was at 35C, not bad, but not good either. I wanted to replace the stock cooler with the Cooler Master Hyper 212+ but no one had immediate stock so I had to take whatever was on stock at the first computer shop that had any CPU coolers.

Zalman S9700

This turned out to be a Zalman S9700 LED, which is a massive heat sink and heavy, 790g heavy, so mounting that vertically in my case seems a bit excessive. The good news though is my CPU idle at 22C and with average use it goes up to 35C. I still need to stress test the new cooler.

I will also run some benchmarks. The current feeling is that this machine is very very fast. Running a VM and developing on the host at the same time is no problem at all.

Friday, September 10, 2010

PC Upgrade 2010

My current development PC at home is getting close to 3 years old now. I decided it was time to do an upgrade.

I browsed and read lots and lots of blog posts and articles around the different CPUs available and eventually settled on the Intel i7 870.

I like the new Turbo Boost functionality on the i7, but the i7 870 was priced well. I also prefer dual channel instead of triple channel so the 870 seemed to be a good fit.

Dual channel also means my motherboard was cheaper than the triple channel versions.

I am not into over clocking at all, so I settled for a motherboard that does what I need and nothing more. I did investigate its performance on some of the well known benchmarking websites.

The MSi board performed on par with all the other expensive boards, the only thing about the MSi board is that over clocking is not its claim to fame, which is fine with me.

The RAM in my new machine will be OCZ DDR 3 1333MHz, a full 8Gb. I bought the OCZ RAM because it was on special at Take2.co.za.

The RAM also looks nice.

I also decided to make an investment in the new SSD hard drives. This SSD was expensive compared to what I could get if I bought a normal hard drive, but according to all the benchmark tests the difference in speed will be huge.

Only problem is I will only have 60Gb space, so I will need to micro manage my hard drive usage again like back in the 90's.

Hard drives are so big and cheap lately, that I almost never delete files any more.

My PC components should arrive on Monday, so Monday night will be PC building night.

Thursday, August 12, 2010

Source Code Highlight in Blogger

I always wanted to have syntax highlighting in my blog posts but I thought Blogger didn't allow it. Thankfully I was wrong.

The code snippet below shows how pretty it can look. I am using SyntaxHighlighter version 3.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace Core.EFT.XXX
{
    /// 
    /// This class will decode the XML from the XXX service.
    /// 
    public class XXXTCPResponse : TCPResponse
    {
        #region Properties
        /// 
        /// The request type.
        /// 
        public string RequestType { get; set; }
        #endregion
    }
} 

I will probably start posting more C#, C++ and Java code snippets on this blog.

Thursday, August 24, 2006

Why I like VMPlayer

I am using VMWare's VMPlayer extensively now and a feature I only recently discovered is that the VMPlayer will dynamically change the resolution of the guest OS when I resize the VMPlayer window, thus it is possible to have unlikely resolutions of 433x900 etc.

To me this is great, I can now run my VM alongside my other applications and it looks like just another application actually. I have a screenshot available just to give some background to why I am so impressed, just be warned it is a 1920x1200 PNG image.

Tuesday, July 18, 2006

VMware Player vs. Workstation

I am currently using VMware Workstation 5.5 to do my Windows development on my Ubuntu laptop, the problem is I need to buy VMware Workstation to keep on using it and I do not really have $189 to spent on it, especially since I am only using it run Microsoft Visual Studio 2005.

I considered using the VMware Player instead but could not find any meaningful benchmarks or comparisons so I decided to download SiSoft Sandra 2005 and do some tests myself and I am very impressed with the Player's speed.

I am not allowed to publish any benchmarks but suffice to say that I will be using the free VMware player to do my development on from now on and not the VMware workstation anymore.

Friday, May 05, 2006

BPEL4WS

Something I need to research very soon is BPEL4WS. It all sounds very exciting and promising but I still need to do an in depth analysis of it.

Exceptions and Error Code

I was pointed to this article by a colleague. Brad Adams is one of the guys I really respect when it comes to .NET. I whole heartily agree with his statements. Exceptions just plain and simple RULE! I lack any other better word for them.

Tuesday, May 02, 2006

Great AJAX Frameworks

I stumbled across this blog. It contains a list of a few AJAX frameworks the author has tried out or used before. Definitely worth a quick glance.