Archive for the 'Programming' Category

Write Entry to Eventlog using VB.NET

Are you a VB.NET programmer who’s ever looked through the windows eventlog (eventvwr.exe) thinking to yourself “How can I get my program to write events to the eventlog”? Here’s how:

Public Function WriteToEventLog(ByVal Entry As String, Optional ByVal AppName As String = "VB.NET Application", _
Optional ByVal EventType As EventLogEntryType = EventLogEntryType.Information, Optional ByVal LogName As String = _
“Application”) As Boolean

Dim objEventLog As New EventLog

Try
‘Register the App as an Event Source
If Not objEventLog.SourceExists(AppName) Then

objEventLog.CreateEventSource(AppName, LogName)
End If

objEventLog.Source = AppName

'WriteEntry is overloaded; this is one
‘of 10 ways to call it
objEventLog.WriteEntry(Entry, EventType)
Return True
Catch Ex As Exception
Return False

End Try
End Function

The function WriteToEventLog has 1 parameter (entry to write to event log) with 3 other optional parameters specifying the Application Name, Event Type raised (Information, Warning, Critical) and the logname (whether the entry is written to Application, System, or other log within the event log).

I find this very useful especially in very large applications where writing an external log (besides .txt or .log files) becomes tedious. Writing entries into the event log is really create when you’re writing windows services also.

Hope this helps, please feel free to send me an email if you have any questions.

Windows developer dumps “pile of crap” for MacOSX

Pete Wright who is was a programmer for Microsoft Windows one day dreamed of joining Microsoft to contribute to the computer industry and really change the way people use computers.

I dreamed of working at Microsoft. When Microsoft joined up with Accenture to form Avanade the word ‘consultant’ sounded so wonderfully romantic to me and I wondered if ever I’d make it there as one of the elite band of Avanade consultants, spreading the Microsoft message all over the world. I dreamed of systems that would change lives, help people, and do cool new things never seen before”  - Pete Wright (MacDailyNews).

Now how things change so quickly. Everybody who knows anything about computers knows that Microsoft’s flagship product ‘Microsoft Windows’ is a spaghetti code situation at best, once with the idea that complexity in how an operating system is designed would better the overall product has eventually ended up with a product that is a nightmare to code for, and almost a bigger headache for an end-user to use.

So Pete has done what many programmers im sure have thought at Microsoft before, he has jumped ship to go work for Apple Computer to work on a project which prides it self on end-user simplicity, and a much more managable code-base…Apple MacOSX.

To read all about Pete’s experiences with working with Microsoft and his jump into MacOSX, be sure to check out his blog entry entitled “Goodbye Microsoft, Pete has left the building!”. It is really interesting and well worth a read if you are a programmer youself or student with the same dream of working with Microsoft has Pete once had.

Programmers need to stop writing code?

I read an article recently on The Inquirer which discusses why software developers should stop writing code from scratch, and start learning to be ‘agile’ and recycle existing code.

“Apparently the keys to unlocking the “agility paradox” are architecture, a focus on software process and engineering, and recycling” - Nick Farrell, The Inquirer

Sure, programmers are definately not going to loose their jobs based on opinions in this article, they will still need to be there to assemble a variety of packages to implement greater functionality in whichever software project they are working on. As a programmer myself (BCompSc, final year), I have noticed that over the years, especially with the introduction of the .NET framework by Microsoft, that work is being done to cut down the workload of a programmer by the amount of ‘fresh code’ they need to come up with to make a program functional.

The idea of reusing or recycling code has been around for quite some time, probably ever since modern programming languages have been around. A programmer could write a new class() which provided ‘x’ functionality, and could keep reusing that class wherever and whenever he needed that same functionality over again, whether it be in the same or different projects.

My main languages I code in are C/C++, JAVA and VB.NET (.NET framework, I should probably learn Visual C# or something too hehe). Whenever I switch between these various languages to program in the .NET environment, you can really notice a big different in the amount of code you need to write to achieve a similar result as you would get if you wrote the same program in C++ for example. Microsoft’s .NET framework includes a vast amount of ‘pre-defined’ code if you will, objects that can be reused to save time.

I noticed this when the .NET framework v2.0 was released, and started using Visual Studio.NET 2005, we programmers had access to a bevy of new and interesting functionality at our fingertips. No new code needed to be written as we could simply recycle objects and code from which had already been writen and provided to us by .NET. One new object which stands out in my head is the Web Browser object which provides web browsing functionality to an application with basically no extra code required.

I also remember a week ago I think, I read an article online somewhere (forgot exactly where) which discussed how programmers spend their time predominantly whilst they are programming. Either writing code, modifying existing code or understanding code written by other developers. The biggest chunk of time amongst many programmers (~60% est.) was when they were sitting there, reading and understanding other’s code, then (~30% est.) modifying existing code and finally on average (~10% est.) of programmers would actually be writing new code.

Don’t take this data I just spewed out at you as accurate, but based on these estimates, you can see that many programmers don’t write new code these days as it is, so have these guys at ‘The Inquirer’ totally lost it in this recent article, saying that programmers “need to stop writing code”?

At Gartner’s Application Development Summit event recently, Matt Hoyle (Gartner Analyst) gave a keynote speech saying, “The future of application development is not about programmer productivity,”…”but in assembling functionality from components.”

I Think this couldn’t be more true, especially with everything I just talked about earlier about reusable objects in the .NET framework for example.

Programmers shouldn’t stop writing code altogether, but the future of Rapid Application Development (RAD) is definately to assemble functionality from existing componments. Who knows, maybe in 20 years time, Software Architect maybe a better term for a programmer. We shall see.

Open Source: changing the world and web

“Lets face it, not everyone is a tech junkie at this stage in their life (I know that I am not) but the further one gets in their college career, the closer we get to the corporate realm, and it is important to note one of the most interesting tech issue revolutionizing our world, open source programming.”

I have been a big advocate of open source software for a long time and have recommended it to many people as a free alternative to many commercial software which typically costs many hundreds of dollars. Not only is it getting something for a whole lot cheaper, but it is introducing amazing new products into a bloated marketplace in much need of rejuvination which open source software can provide.

Check out the artcle via the ‘read more’ link below, a very interesting read.

read more | digg story


Writer's here also write at:

Find Me

Technorati blog directory goblink.gif



del.icio.us

Associations

Listed on BlogShares

Spam Blocked - Take that!

Are you apart of the croud?

  • 184,580 people can't be wrong!

The Whole Story Banners

Feel free to use our site's banner on your site to mark us as an affiliate site (approval required).