Operation could destabilize the runtime

I was trying to reproduce Repository pattern that Rob Conery was using in his MVC Store Front project in my own project.


Continuing with the interface programming style hype, I decided to make everything implement some sort of an interface.  So my domain object (say Person), will implement IPerson interface and so on.

So I have an IPersonRepository that will have a couple of implementations.  One for testing (TestPersonRepository : IPersonRepository) and a real Linq To Sql implmentation (SqlPersonRepository : IPersonRepository).

The repository has one method, which is IQueryable<IPerson> GetPersons() that will return all the available persons.

My test which was using the TestPersonRepository implementation works well.  But when I tried integrating my code using the real Linq to Sql implementation, it blew up.

The code for the SqlPersonRepository implementation is as follow:

   1:  public IQueryable<IPerson> GetPersons() 
   2:  {
   3:      var db = new Data.Linq.SampleDbContext();
   4:   
   5:      var query = from p in db.Persons
   6:                      select (IPerson) new Domain.Person {
   7:                        FirstName = p.FirstName, LastName = p.LastName
   8:                      };
   9:   
  10:      return query;
  11:  }

As you can see, I was trying to cast Person to IPerson in the Linq query.  This apparently didn't work. Hehehe.  Changing all my interface to IQueryable<Person> and removing the casting will make it work.

Another work around that I found to work is using the following code:

   1:  public IQueryable<IPerson> GetPerson()
   2:  {
   3:      var db = new Data.Linq.SampleDbContext();
   4:   
   5:      var query = from p in db.Persons
   6:                          select p;
   7:   
   8:      IList<IPerson> results = new List<IPerson>();
   9:   
  10:      foreach(var p in query)
  11:      {
  12:          results.Add(new Domain.Person { FirstName = p.FirstName, LastName = p.LastName });
  13:      }
  14:   
  15:      return results.AsQueryable();
  16:  }

 

Sucks :)

Anyone want to take a stab at what's going on here?

Share this post: | | | |

How to Make Yet Another Forum.Net to Work with Telligent Graffiti CMS

In a recent project that I was handling, there was a requirement to have a forum on top of an existing Graffiti CMS.  Instead of building one from scratch I decided to look for an open source .NET forum engine alternative.  That's when I ran into Yet Another Forum.Net.

The task is simple enough.  add a forum virtual directory and when someone click a link to http://blah/forum, YAF.NET should work.

After downloading the forum distributable and adding it as a Graffiti CMS virtual directory, some problems start showing up.

You can follow some steps described in the YAF.NET Installation Steps  section in their Wiki to mitigate the problem but it doesn't get you 100% there.

Playing around with it, I managed to get it to work with the following steps:

  • - Get YAF.NET to work as a standalone application (setup db, etc.).  If you can get it to work, you are about 90% there.
  • - Remove YAF.NET application from IIS Manager
  • - Add YAF.NET directory as a virtual directory of Graffiti or copy the entire YAF.NET directory to Graffiti root folder/forum. I.e. if you Graffiti CMS is installed in D:\Graffiti\Web, then copy YAF.NET content to D:\Graffiti\Web\Forum
  • - Copy all bin folder contents from YAF.NET directory to Graffiti bin folder
  • - Copy yafnet.config and urlrewriter.config to root directory of Graffiti
  • - Make sure to rename the web.config in YAF.NET directory back to default.config so it does not run
  • - In Graffiti CMS web.config, you need to make some modifications like:
  • - copy the configSection from default.config in YAF.NET directory across
  • - copy <yafnet ...> and <rewriter ...> from default.config across
  • - create a <location path="forum"> in Graffiti CMS web.config and copy the <system.web>...</system.web> from default.config into the <location...> tag.
  • - Make modification to <pages ...> tag in the newly copied part in the previous step.  You need to copy <namespaces> and its content from Graffiti web.config and change <add namespace...> to <remove namespace...>

That's it.  Test both Graffiti CMS and the newly integrated YAF.NET to make sure they work.

Attached is a sample of the modified Graffiti CMS web.config

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Interesting MVC Sample Project

I was listening to some podcasts or other, I think it was one of the Herding Code podcasts, where they interview Rob Conery and his sample MVC project.  In which he walked you through the process of creating this MVC Storefront using ASP.NET MVC, TDD, LINQ, Dependency Injections, etc.  The format of it is a webcast that you can download and playback at your own leisure.

Along the way he consulted other experts in the .NET world such as Ayende Rahien (Oren Eini) of NHibernate and RhinoMock fame, Jon Galloway, etc.

If you are interested in doing MVC and this type of stuffs, I strongly suggest you take a look at his webcasts.

You can find the stuff here.

Rob is also the creator of Subsonic (data access layer scaffolder / mapper or something for lack of better term).

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: , ,

100% Customized Development Effort vs Customization of Available Solutions

Sometimes, and I am also guilty at this as well, we tend to want to develop a fully 100% customized solution from the very beginning, may it be an ASP.NET website or otherwise.  After all, what fun is it in trying to customize someone else's code, right?  Sometimes, it's just because we are not familiar with or don't have the time to look around / research what's out there that someone else has already built that might suit our project requirements.

Nowadays, I am of the opinion that spending your time looking around and trying to find out if there is such solution is really worthwhile and could really help you deliver the solution faster.

Of course, even if you do find the solution, you will still need to analyze if you need to further customize it or not.  Perhaps the current solution will only cover 80% of your current requirements and you will need to spend time to fill in the 20% gap doing further customizations.

Sometimes such solution package is not too extensible, then you will need to consider what to do about the rest 20%.  Do you build an 'out-of-bound' customized solution to fill in the gap?  Can you hook it up to the lower level implementation of the current solution? i.e. go straight to the database and mess around with it?  Those are risks that you will need to spend your time thinking about.

Another consideration that you need to take is how long will it take you and your team to figure out all the extensibility points of the current solution?  Will it be longer than if you actually build up your own solution from scratch?  In most cases, the answer will be no (time to customize an existing solution will not take longer than building one from scratch).  But reflect on this point as well since you might find the answer is contrary to common thinking.

Just rambling on a thought that came into my mind during one of the projects that I'm doing.  I hope this can be of use to you.

Happy analyzing :)

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: , ,

Reflecting over Software Usability

I was entertaining my two and a half year old boy a couple days back.  I'm just amazed on how quick kids nowadays can adapt to technology.  At that age, he already mastered how to use the mouse to navigate, click and drag and drop stuffs.

Lately he's been hooked on Scott Hanselman's Baby Smash, YouTube kids videos like the Alphabet Song, etc. and Sesame Street website which is full of games and activities for kids his age.

I can give him instruction already on how to use most of the stuffs that are on the screen (i.e. go click that red button there, or just drag the lemon to the jug, etc.)  and he could execute the instruction just fine.  Recently, I don't even have to tell him how to switch between YouTube videos, etc.  He'll do it by himself.  As a matter of fact, he'd push me aside so not to disturb him having fun.

One thing that amazed me recently is that he seems to understand on how to use the environment like Vista without me telling him the stuffs up front.  For example, one time we had FireFox running YouTube, Internet Explorer running a JavaScript HTML application that I built for him (bouncing box with numbers that keep changing color and a bunch of stuffs that you can do to the boxes) and a media player running one of his favorite videos.  By accident, he discovered that if he hovered near the taskbar, Vista will give you a preview of the application in a thumbnail.  As I watched him playing around with the mouse, I simply post a question to him asking if he could find out how to bring up the Sesame Street session (it was minimized at that time) and he instinctly knew that if he did the hover action, he could figure out which application is running Sesame Street and by clicking on it he was able to bring up IE to the front.

Now, I don't know if this is a testament of the UX brilliance of the Vista team or my kid is just plain smart, lol.

Just thought I share that with you all.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Debugging Adventure Fun Episode eerr... Whatever

I was recently asked to debug a legacy Access 97 (YES, Access 97, lol) database frontend application that is connecting to a SQL Server 7 (Yes, SQL Server 7, lol) backend (Like I said... it's legacy, what do you expect ^_^).  To make things worse, I had to debug this through a remote VNC session since the problem is occuring somewhere in Kalimantan and I am in Jakarta.  What fun :), ... NOT! Tried debugging it on a local copy that I have (in VM of course, heck, I am not going to install Office 97 stuffs on my main machine, hehehe, although I did this once before when I didn't know better, hehehe.  It did work however - side by side Office 97 and Office 2003 installation, haven't tried to do it with Office 2007, nor do I want to - btw, you have to do some tweaking here and there, but it worked.  Uhm... Sorry for digressing... Back to laptop, as they said it...), but couldn't reproduce the error no matter what I do.  The application ran just fine on the VM.  So, the next logical step is to debug it where the problem is actually happening.

Anyhow, the problem presented to me was an error that kept showing up recently that stumped some unknown code module in the system (The error message provided is very generic like 'Unable to fullfil your request', apparently the person who created the application was well versed in security issue, you know... not exposing the internal system error to the client / user, but he forgot to log the real freaking error somewhere else for easy debugging...ARRGH. Oh, btw, if your Access application is hooked up to run some code automatically on load, you can launch it by holding down Shift key and double-clicking the .mdb file to stop the code from running.  Sometimes this is necessary to allow you access to the object viewer, etc.  Uhm... Back to laptop... (who the heck invented that phrase anyway...)

After setting numerous breakpoints and tracing the code from the startup form up to the point of failure (what a chore... stupid VNC won't allow me to press F8, argh, so I have to click on the VBA debug menu item one click at the time to step into / through some code).  Oh, did I mentioned the sucky connection between Jakarta and our site in Kalimantan (in the middle of nowhere, literally in jungle, mining site)?  Yeah, the VNC connection broke down on multiple occassions!! OMG.  Speaking of hellish debugging session... Sigh. Ok, enough digressing... Back to laptop...

Erhmm... Where were we... oh yeah, after blah blah blah breakpoint, blah, and so on and what not... sigh... it turned out that the error was caused by a SQL Query that is constructed using string concatenation like:

 

"SELECT Field1, Field2 FROM SomeTable " + _
"WHERE Timestamp = '" + FormatMySillyDate(Now()) +"' " + _
"AND some other criteria here (not important)..."

 

And when the query got shoved to SQL Server through DAO, SQL just said huh? what date are you talking about... that's not a date!! and gave up.

Aside from the abysmal lacking of clear exception information available from the error handling routine that made debugging this application a hellish experience (oh and the VNC, and the network, etc. etc.), my gut instinct pointed me that this could be a localization issue.  Since it worked perfectly on my VM (couldn't reproduce the error, remember?), it's clearly local to this one workstation (and it was confirmed by the operator that the one installed on the other computer is working just fine.)  So... after confirming that the formatted date being passed is something like '18-Agust-2008', next step that I took is take a look at the Regional Settings of the computer and sure enough, it was set to Indonesian localization :).  Changing this back to English (United States), fixed the problem.

 

After strongly warning the user about the "danger" of switching Regional Settings unilaterally and forwarded the issue and resolution to the support (help) desk team (just in case, in the future...), I finally could rest in peace, phew... (or if the boss is watching, rest in peace == back to working hard on the gazillions of other projects, simulteneously, and maintenance issues)  There goes 2 hours of my life that I'll never get back.

 

Moral of the story is... you figure it out. I am beat (mentally) from debugging this... (^_^).

 

I apologize for rambling too much, but didn't you read my blog title? Hehehe.

 

p.s. Any exaggeration is purely for comical effect and not to be taken seriously.  Funnier to read that way... Bah, why am I explaining this... Sigh.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: , ,

New Cool Stuffs in Team Foundation Server 2008

Installed Team Foundation Server 2008 Workgroup Edition a couple of days back and been playing around with it.

One thing that I like about TFS 2008 is that they revamped the build process so now you can do Continuous Integration (build when you check-in) / Nightly, and other build settings right from inside VSTS / Team Explorer.  Awesome!! :)

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:

Apparently VS 2008 SP 1...

Apparently, if you install Visual Studio 2008 Service Pack 1, you don't need to install .Net Framework 3.5 SP 1 anymore (already included).  It also installed .Net Framework 2.0 SP 2 and .Net Framework 30. SP 2... Apparently.

Btw.  What's in the SP2s?  Can't find those online to download separately.

Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Tabular XML Data to Hierachical XML Data Translation with XSLT

On previous post, we discussed creating a hierarchical XML from tabular data using only T-SQL.  

On this post, we'll explore transforming tabular data in XML format to a hierarchical XML format using purely XSLT.

Let's say that we have an XML that is pretty tabular like the one below.

<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="[replace with the real stylesheet filename here].xsl" ?>
<Mappings>
    <Mapping>
        <Station>Science</Station>
        <Crew>Spock</Crew>
    </Mapping>
    <Mapping>
        <Station>Command</Station>
        <Crew>Kirk</Crew>
    </Mapping>
    <Mapping>
        <Station>Engineering</Station>
        <Crew>Scotty</Crew>
    </Mapping>
    <Mapping>
        <Station>Medical</Station>
        <Crew>Bones</Crew>
    </Mapping>
    <Mapping>
        <Station>Science</Station>
        <Crew>Ensign Disposable</Crew>
    </Mapping>
    <Mapping>
        <Station>Medical</Station>
        <Crew>Nurse Hatchet</Crew>
    </Mapping>
</Mappings>

Fig 1. Tabular Star Trek Crew to Station Mapping xml

 

And we want to transform it into something like:

<Mappings>
    <Station>
        <Name>Command</Name>
        <Crews>
            <Crew>Kirk</Crew>
        </Crews>
    </Station>
    <Station>
        <Name>Engineering</Name>
        <Crews>
            <Crew>Scotty</Crew>
        </Crews>
    </Station>
    <Station>
        <Name>Medical</Name>
        <Crews>
            <Crew>Bones</Crew>
            <Crew>Nurse Hatchet</Crew>
        </Crews>
    </Station>
    <Station>
        <Name>Science</Name>
        <Crews>
            <Crew>Ensign Disposable</Crew>
            <Crew>Spock</Crew>
        </Crews>
    </Station>
</Mappings>

Fig 2. Hierachical Star Trek Crew to Station Mapping xml

 

You can use the following XSLT to do it:

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:ms="urn:schemas-microsoft-com:xslt" 
                version="1.0">
    <xsl:output method="xml" indent="yes" />
 
    <!-- Store unique station names in variable -->
    <xsl:variable name="uniqueStations" select="//Mapping[not(Station=preceding-sibling::Mapping/Station)]/Station" />
 
    <xsl:template match="/">
        <Mappings>        
            <xsl:call-template name="processStations" />
        </Mappings>
    </xsl:template>
    
    <xsl:template name="processStations">
        <xsl:for-each select="$uniqueStations">
            <xsl:sort select="." data-type="text" />
            <Station>
                <Name><xsl:value-of select="." /></Name>
                <xsl:variable name="currentStationCrews" select="//Mapping[Station=current()]/Crew" />                
                <Crews>
                    <xsl:for-each select="$currentStationCrews">
                        <xsl:sort select="." />
                        <Crew><xsl:value-of select="current()" /></Crew>
                    </xsl:for-each>
                </Crews>
            </Station>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Fig 3. XSLT Needed for the Transformation

 

Frankly, I don't quite like this particular XSLT format since it is quite imperative in style (for each looping), but I couldn't find a more declarative template matching solution for this.

 

If anyone know a better solution, let me know.

 

One part that I like from this particular sample is by adding

<?xml-stylesheet type="text/xsl" href="[filename].xsl" ?>

to the xml file like in Fig. 1, you can test the transformation quickly just by invoking the xml file from a browser (Internet Explorer / FireFox will do this nicely).  The only thing is that you can't really see the actual tag on screen.  To quickly verify the resulting transformed XML, you can enter the following JavaScript code into the URL bar of your browser:

BLOCKED SCRIPTalert(document.documentElement.innerHTML)

 

Giving credit where credit is due... I used this ASP Alliance article by Teemu Keiski as base for this solution.

Share this post: | | | |
Posted by Jimmy Chandra | 3 comment(s)
Filed under: ,

Transforming Denormalized Tabular Data to Hierarchical XML Using SQL Server (2005)

A friend of mine asked me today if there is any easy way to transform a table / query result that is quite tabular like the one in the table below to a hierarchical XML format just by using T-SQL query.

Id Product Activity
1 Product A Activity A
2 Product A Activity B
3 Product B Activity C
4 Product C Activity D

Fig 1. ProductMapping Table

 

<products>
    <product>
        <desc>Product A</desc>
        <activities>
            <activity>Activity A</activity>
            <activity>Activity B</activity>
        <activities>
    </product>
    <product>
        <desc>Product B</desc>
        <activities>
            <activity>Activity C</activity>
        <activities>
    </product>
    <product>
        <desc>Product C</desc>
        <activities>
            <activity>Activity D</activity>
        <activities>
    </product>
</products>

Fig 2. Expected XML Result

 

Although I dabble in XML, XPATH, XSLT and the like from .NET / JavaScript; I've never really touched SQL Server XML features that much so I decided to play around a little with it.

The only thing I remember about T-SQL and XML is that they have this FOR XML keyword that will allow you to transform table data to XML ... somehow.

After a bit of researching and trial and error, I came up with the following T-SQL Query:

SELECT 
    DISTINCT product AS "desc",
    (
        SELECT 
            activity AS "*"
        FROM 
            ProductMapping m2
        WHERE 
            m2.product = m1.product
        FOR XML PATH('activity'), ROOT('activities')
    ) 
FROM
    ProductMapping m1 
FOR XML PATH('product'), ROOT('products')

Fig 3. First T-SQL attempt for transforming tabular data to XML

 

This gets me pretty close to what I want, but for some reasons the subquery result is HTML encoded.

<products>
    <product>
        <desc>Product A</desc>
        &lt;activities&gt;
            &lt;activity&gt;Activity A&lt;/activity&gt;
            &lt;activity&gt;Activity B&lt;/activity&gt;
        &lt;/activities&gt;
    </product>
    <product>
        <desc>Product B</desc>
        &lt;activities&gt;
            &lt;activity&gt;Activity C&lt;/activity&gt;
        &lt;/activities&gt;
    </product>
    <product>
        <desc>Product C</desc>
        &lt;activities&gt;
            &lt;activity&gt;Activity D&lt;/activity&gt;
        &lt;/activities&gt;
    </product>
</products>

Fig 4. Bad XML!!

 

After researching a little bit more and could not find a satisfactory and clean answer to do this, I finally just gave up and wrapped the above T-SQL in another SELECT statement with a bunch of replace functions surrounding it to transform all the &lt; and &gt; to actual < and >.

SELECT 
    replace(
    replace(
    (
        SELECT
            DISTINCT product AS "desc",
            (
                SELECT
                    activity AS "*"
                FROM
                    ProductMapping m2
                WHERE 
                    m2.product = m1.product
                FOR XML PATH('activity'), ROOT('activities')) 
        FROM
            ProductMapping m1 
        FOR XML PATH('product'), ROOT('products')
    ),
    N'&lt;', N'<'),
    N'&gt;', N'>') AS [Products XML]

Fig 5. This T-SQL gets me what I want but it's not really elegant.

 

Anyone know a better T-SQL only way to do this?

Share this post: | | | |
Posted by Jimmy Chandra | 1 comment(s)
Filed under: ,

What Version of K2 [blackpearl] am I Running?

Note to self:  To quickly see what version of K2 [blackpearl] you are currently running, just go to Control Panel, Add Remove Program and it should be there as part of the product name.

Needed this information when submitting a ticket to K2 Customer portal and I didn't quite recall what latest version was running on our production server.  Took a guess and it turned out to be wrong.  Chatted with K2 support and they told me how to quickly get that info.

Now, why didn't I think of doing that before?  Hehehe.

emoticon
Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:

Setting Destination Users as Mail Event Recipient in K2 BlackPearl

So, I was working on a K2 BP workflow project.  One of the requirement for the project is to email a bunch of users (ideally those belonging to a role of some sort) when something happen.  So far, so good.  It seems simple enough. 

With that in mind, I created the role in K2 BlackPearl Management Console, launch Visual Studio and created a K2 Workflow project, drag a Default Activity from my toolbox, quickly configured my Destination Users to the role that I created previously and finally, I drag a Mail Event to the Activity.  The configuration dialog for the mail event came up and I started filling in details of the email. 

When I want to specify the current Activity's Destination User as my mail recipient I got a little surprised.  It's not checkable!  Oh my...

I cancelled out from the screen since I couldn't really do anything else except Cancel at this point.  Went back to the Activity Property dialog and made sure that I have Destination Users for it properly selected (which they are).

emoticon

What's going on here??? I did this before on another project and I was able to do just that (check the Destination User as the recipient in my mail event, albeit I did encounter something similar to this situation but somehow managed to get it to work).  How come it wouldn't let me do it this time?

After trying a couple more times and feeling frustrated, I decided to throw the towel and asked for help.  After chatting with a resource at SourceCode APAC (DC), he informed me to do the following:

     you need to change the dests to use "Plan per slot"

    by default it uses "Plan once" option and the mail code isnt clever enough to get the list of users at run time

Armed with the knowledge, I recalled doing something like this on the previous project.  Something involving running the Activity Destination Users Wizard in Advanced Mode.  So I went back to my Activity property dialog and choose Destination Users icon from the left side and clicked the Back button to get the Welcome screen (that has this option).  Ticked the checkbox and clicked next again.

Once I clicked next, I arrived at the Destination Rule Options Dialog page.  From here I can choose other Options instead of the default Plan just once option.  DC suggested Plan per slot, but actually Plan per destination will also work and in this case, I think is the more appropriate choice for me.

I continued setting up my Destination Rule to fit my requirement (send notification and let anyone in my destination users (role) complete  the task and move on to the next step).

Once I'm done with the activity's Destination Users setup, I went back and insert a Mail Event into the activity and look what I can do now...

Thanks, DC.

emoticon
Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under:

DataSet Xml Deserialization Data / Schema Load Order

Note to self:

When deserializing a dataset from xml, make sure to execute ReadXmlSchema before executing ReadXml, otherwise you'll have problem when you try casting your data into the correct data type.

using System;
using System.Data;
using System.IO;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            //Serialize the sample data
            var ds          = InitDataSource();
            var dataXml     = SerializeData(ds).ToString();
            var schemaXml   = SerializeSchema(ds).ToString();
 
            //Example of bad order
            var dsBad = new DataSet();
            dsBad.ReadXml(new StringReader(dataXml));
            dsBad.ReadXmlSchema(new StringReader(schemaXml));
 
            Console.WriteLine("Bad Example Result:");
 
            try
            {
                Console.WriteLine(
                    string.Format("{0}:{1} {2:N2}",
                        (int)dsBad.Tables[0].Rows[0][0],        //Will throw exception here
                        dsBad.Tables[0].Rows[0][1],
                        (decimal)dsBad.Tables[0].Rows[0][2]));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
 
            Console.WriteLine();
 
            //Example of good order
            var dsGood = new DataSet();
            dsGood.ReadXmlSchema(new StringReader(schemaXml));
            dsGood.ReadXml(new StringReader(dataXml));
 
            Console.WriteLine("Good Example Result:");
            Console.WriteLine(
                string.Format("{0}:{1} {2:N2}",
                    (int)dsGood.Tables[0].Rows[0][0],
                    dsGood.Tables[0].Rows[0][1],
                    (decimal)dsGood.Tables[0].Rows[0][2]));
 
            Console.WriteLine();
            Console.WriteLine("Press any key...");
            Console.ReadLine();
        }
 
        private static StringWriter SerializeSchema(DataSet ds)
        {
            using (var sw = new StringWriter())
            {
                ds.WriteXmlSchema(sw);
                return sw;
            }
        }
 
        private static StringWriter SerializeData(DataSet ds)
        {
            using (var sw = new StringWriter())
            {
                ds.WriteXml(sw);
                return sw;
            }
        }
    
        private static DataSet InitDataSource()
        {
            var ds = new DataSet("Foo");
 
            //Setup Sample DataTable
            var dt = new DataTable("Bar");
            dt.Columns.Add("Id", typeof (int));
            dt.Columns.Add("Description", typeof (string));
            dt.Columns.Add("Price", typeof (decimal));
 
            //Populate with Sample Data
            dt.Rows.Add(1, "Banana", 6.05m);
 
            ds.Tables.Add(dt);
            return ds;
        }
    }
}
Share this post: | | | |
Posted by Jimmy Chandra | with no comments
Filed under: ,

Silly Design Decision?

Silly-TL-placement

Just a bit of disclaimer up front... This is purely based from my point of view / observation and I don't claim to have any prior knowledge or understanding on why this thing is designed this way, so I might be completely wrong.  If so, please let me know.

Every morning, I usually pass by this particular street crossing (Panglima Polim and Panglima Polim 9 from Barito to go toward Darmawangsa) to get to work (See attached map below).

And usually if I am lucky, the traffic light at Panglima Polim will be green by the time I arrived at the intersection, but this is not the case most of the time.

Having nothing better to do I started looking around and let my mind wonder about.  One thing keeps coming up in my mind as I looked around the area and it really bothers me a lot.

If you see the picture to the left, you can see the 2 traffic lights, one at Panglima Polim crossing and another one 1 street parallel to the first traffic light and the distance between the two is probably not more than 30 meters. 

 

As you can see, this can be quite a dilemma, especially if there are a lot of traffic coming from Barito that is going on toward Panglima Polim 9 and this is happening quite often.  What happen next, you can imagine for yourself.  The tail of the traffic going toward Panglima Polim 9 will block the perpendicular traffic of Panglima Polim since the two traffic lights are not even synchronized!  Meaning if the first traffic light is green the one after that is actually red!  So you moved a little across Panglima Polim and stopped right away for the next traffic light.

 

 

 

Cybermap: Panglima Polim

Map image from Cybermap.

I wonder why the need for the second traffic light at all.  I believe it does more harm than good.  I am also wondering what kind of analysis had been done before putting the second traffic lights in place.  I am wondering what kind of process was used to decide to put this silly traffic lights configuration.  Last but not least, what can you do to remove it or at least turn it off completely (the second traffic light).

 

One agitated Jakarta road user.

Share this post: | | | | </