TexasSwede
texasswede@gmail.com
  • About this blog
  • My Website
  • My Resume
  • XML Export Tool
  • Photos

Monthly Archives: October 2012

Replace images on web page using jQuery

Posted on October 31, 2012 by Karl-Henry Martinsson Posted in Frameworks, Javascript, Notes/Domino, Programming, Web Development 3 Comments

Last week I encountered a situation where I wanted to replace images on a Domino generated webpage. I am sure you all know what doc links look like by default when rendered by the Domino HTTP task:

Domino Default Icons (click for larger version)

 

By adding a few lines of jQuery to the form, you can manipulate the image source, as well as the CSS class and other attributes. This allows you to modify a page served by the Domino HTTP task almost as much as you like.

Below is the code I used to modify what you see above into something that I found a little bit nicer.

        $("img").each( function() {
        var t = $(this);
        imgicon = t.attr("src");
        if (imgicon == "/icons/doclink.gif") {
           t.attr('src', '/applications/losscontrol.nsf/icon_picture.gif');
           t.addClass('photoicon');
        } 
        if (imgicon.indexOf("Attachments") > 1 ) {
           t.attr('src', '/applications/losscontrol.nsf/icon_attach.gif');
           t.addClass('attachmenticon');
           t.attr('height','16');
           t.attr('width','16');
        } 
    });
    $("a").each( function() {
        var t = $(this);
        url = t.attr("href");
        if (url.indexOf("$FILE")>0) {
           t.removeAttr("style");
           t.addClass('attachmentLink');
           t.outerHTML = t.outerHTML + "<br>";
        }
    });
    var plink = $('#photolinks').html();
    plink = plink.replace(/<br>/i,'');
    plink = plink.replace(/<\/a><font\b[^>]*>/gim,'<span class="photoLink">');
    plink = plink.replace(/<\/font>/gim,'</span></a>');
    $("#photolinks").html(plink);

    var alink = $('#attachmentlinks').html();
    alink = alink.replace(/<\/a>/ig,'</a><br>');
    $("#attachmentlinks").html(alink);

 

What I am doing is to loop through all img tags on the page, and identify the ones that are doc links (using the file name for the icon). I replace the src attribute of those links with a different icon I added as an image resource to the database. I then set the class name for the link, so I can manipulate the look using CSS.

I also look for any src attribute containing the field name “Attachments”, which is where the attachments (if present) are located. I change the icon from the one generated by Domino to another image resource in the database.

The next section of the code will loop through all anchor tags and check if the link includes “$FILE”, indicating it is an attachment. If that is the case, I remove the Domino generated style attribute, set a class name and append a line break to the end of each link.

I then perform some string replacements to remove the font tags that Domino generate automatically when rendering rich text fields. I replace the font tags with a span (containing a class name) so I can style the look of the link later, and also move the </a> tag to after the link text. The last thing I do is to add a line break after each attachment link.

Here is the result:

Domino jQuery Icons (click for larger version)

 

Hope this can help anyone. And if you wonder, I am using the fieldset tag to create the box around each set of icons.

Domino jQuery

The Night of the Toys

Posted on October 30, 2012 by Karl-Henry Martinsson Posted in Hobbies, Photography 2 Comments

This is an old video, called “The Night of the Toys”, made by me and four classmates when we were in 6th grade. I think it was filmed in the spring of 1982. One week our class was divided into groups of 5-6 students and each group then wrote and filmed a short movie. Most groups used one of the early (and huge) camcorders, but my group (being the overachievers) decided to make a stop-motion movie, using Super 8 cameras…

We shot the movie in a little over a week (using weekends and a couple of extra days our teacher gave to us, if I remember correctly), at the home of one of my best friends, and despite some errors (for example taking just one picture before moving the items, we should have taken two and moved the toys less between the frames) it turned out surprisingly good, if I may say so myself.

Some years ago, my cousin converted the movie into digital format, and I re-cut it using Sony Vegas. I was then able to slow down some of the really fast scenes, and speed up or shorten some other scenes. I also recut the film to avoid some artifacts at the splicing locations, and I also redid the titles from scratch. Finally I added some music and sound effects. You can see the result below. Remember, this was 14 years before Toy Story… Also, the titles are in Swedish.

How to start with jQuery

Posted on October 26, 2012 by Karl-Henry Martinsson Posted in Frameworks, HTML/CSS, Javascript, Web Development Leave a comment

Lately I have been working on several web applications, both as hobby projects and at work. I started using YUI3 a few years ago as a Javascript framework, and I liked it. But I kept hearing about jQuery, and the times I saw code snippets, I was intrigued. It looked different, but at the same time jQuery seemed very powerful and efficient.

So a while back I started looking closer at jQuery, and I found that it was extremely easy to learn. One need a decent understanding of HTML and the browser DOM (Document Object Model), as well as Javascript knowledge. Add some CSS to that, if you want the page to look good as well, and you are set.

So how do you start using jQuery? The easy way is to take advantage of companies like Google and Microsoft who are hosting different frameworks (including jQuery) on their servers for public use. You don’t have to worry about downloading and hosting it yourself, and you can get started in just minutes.

You add code to your page to utilize jQuery, then add some script. You have to allow the browser to wait for the webpage to fully load before you can start doing things, and this is done using $(document).ready(). When that event is triggered, the code you have added there will be executed.

It is very easy to address elements on your webpage. If I have an element (could be a button, a span/div section, a link or even an image) with the id “messageBox”, I can address it like this: $(“#messageBox”). I then have different properties and methods for that element.

But I have always believed in “show me the code”. I created a very simple demo. The webpage contains a button and a div where we want to display a text when the button is clicked. I have some CSS to make the text look nice, and a few lines of jQuery code to do the work.

<html>
  <head>
    <title>Hello, jQuery</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
  </head>

  <script>
  // The following function is executed after page is fully loaded
  $(document).ready(function () {
    // Setup the element with id "btnSave" to react on click
    $("#btnSave").click( function() {
      // When clicked, set the innerHTML of the element with
      // id "messageBox" to the specified html string.
      $("#messageBox").html("You clicked the <strong>Save</strong> button.");
      $("#messageBox").addClass("statusMessage");
    });
  });
  </script>

  <style>
    .statusMessage {
      font-family: Arial;
      font-size: 0.9em;
      color: #AA0000;
    }
  </style>

  <body>
    <button id="btnSave">Save</button>
    <div id="messageBox"></div>
  </body>
</html>

That’s it. Try it yourself, paste this code into a text file and call it jQuery.html, then open it in your browser.

Result of jQuery.html

The result. Click for a larger version.

Now when you understand the basics, you can learn more advanced things. I am using jQuery to very easily perform Ajax calls, even calling Lotusscript web agents to return data from a Domino database to my webpage. I also use it for all kinds of dynamic updates to webpages.

A while back I started on a Domino-based web chat as a hobby project. I started building it using YUI3, but after finishing the initial landing page, I started using jQuery on the actual room pages. The other night I simply ripped out the YUI3 code and replaced it with (much less) jQuery code. It took my just an hour or two. The site/chat is currently in Swedish, but I plan to translate it to other languages, and I will blog more about this project soon. Feel free to try it out, or just look at the source code for the pages. I am sure you will very quickly understand how it works. On that page I use jQuery to call server agent to return the number of users (and their names) present in the different rooms. I also check values in field, as well as update fields, hiding/showing elements on the page depending on field values, etc.
I also use a jQuery plugin to display bubbles with information (pulled in real time from the Domino database using a web agent) when hovering over the count of users in a given room.

 

Lightbox Plus – Thanks Bob Balfe!

Posted on October 26, 2012 by Karl-Henry Martinsson Posted in Blogging, WordPress 1 Comment

Earlier today, Bob Balfe wrote a blog post about installing Lightbox Plus on his blog. I decided to test it on this blog as well, and I really like it. I might make the images I post slightly smaller in the future, as the plugin does not scale down the full-size image is it is larger than the browser window.

Installing the plugin was as easy as it could be. I just selected “Add New”, searched for the plugin,clicked the install button and then activated it. There was a warning that the plugin might not work with the newer version of WordPress I am running, but it all worked for me without any issue. I did not even have to configure anything, the images started showing up in the lightbox automatically. There are a few settings, mainly for the style of the lightbox. But you don’t even need to touch that if you don’t want.

Thanks Bob for posting about this!

Photo – Thunderbirds in Ft Worth

Posted on October 18, 2012 by Karl-Henry Martinsson Posted in Photography Leave a comment

I took this picture the other weekend, and it is one of my favorites from the Air Show. I always enjoyed these kind of demonstrations. It is a little like programming, man in charge of machine. Well, in most cases…

You may not be able to tell, but the number 5 right behind the air intake on the lower F-16 is actually painted upside down, so it appears correct to the spectators. This is because this particular position is flying mostly upside down…

US Air Force Thunderbirds

Thunderbirds performing at the 2012 Ft Worth Airshow.

Fort Worth Airshow 2012

Posted on October 15, 2012 by Karl-Henry Martinsson Posted in Photography 2 Comments

While going to the 2012 Ft Worth Airshow two weekends ago, I took a few pictures. Like a little over 2000… :-) I have processed a few of them, and wanted to show a few HDR pictures I took. The day of the airshow was cloudy and windy, so the sky was fairly gray, and it was a bit dark as well. Perfect conditions to test some more HDR…

A Soviet era Mi-24 Hind.

Here I played a little bit more with the picture…

Moving blog posts from Connections to WordPress

Posted on October 15, 2012 by Karl-Henry Martinsson Posted in Blogging, Lotusscript, Programming 1 Comment

As I switched from IBM Connection to WordPress for my blog, I started thinking about my existing content. Was there a way to move them all over without having to manually copy and paste and recreate all 268 entries?

Well, there is, and this is how I did it, using just a  few tools. First I used Wget to retrieve my old blog. This put all the posts on one folder (entries), and all images in another (resource). It was then a simple task to write a Lotusscript agent that processed each file in that folder and read the content, parsed out the title, date originally posted and HTML for the blog post itself. I put that data into separate Notes documents, after performing some cleanup and string replacement.

I had already moved all images to a filer on my primary web server, so I performed a replace of the image URLs in the HTML, to have any images pointing to their new location. I also had to fix some special characters and replace them with the corresponding HTML entities.

Now when I had all the data, I just wrote another agent to export the data out again, to create a CSV file. I then installed a CSV importer in my WordPress blog and used to to import the file I just created.

After a few tweaks I performed a successful import. Later I realized I had missed a few special characters, so I had to fix those entries, but we are talking about 4 or 5, out of 268 entries.

If there is an interest, I might clean up the code a little and create a nicer UI (right now many of the values like path and URL are hard-coded) and then release the code if anyone else is planning to go through the same exercise. Below is the existing code to read the blog entries into a simple Notes database.

Option Public
Option Declare

Dim entrydir As String
Dim resourcedir As String

Sub Initialize
	Dim filename As String
	Dim cnt List As Integer
	Dim blogentry List As String
	Dim tst As Variant 

	entrydir = "D:\BleedYellowBlog\www.bleedyellow.com\blogs\texasswede\entry\"
	resourcedir = "D:\BleedYellowBlog\www.bleedyellow.com\blogs\texasswede\resource\"

	cnt("Total") = 0
	filename = Dir$(entrydir + "*.*")
	Do While fileName <> ""
		blogentry(filename) = entrydir + filename
		cnt("Total") = cnt("Total") + 1
		fileName = Dir$()
	Loop

	cnt("Processed") = 0 
	ForAll be In blogentry 
		cnt("Processed") = cnt("Processed") + 1
		Print "Processing " & cnt("Processed") & " of " & cnt("Total")  
		Call ProcessBlogEntry(ListTag(be),be)	
	End ForAll
End Sub

Function FixHTML(html As String) As String
	Dim tmp As String

	tmp = Replace(html,_
"https://www.bleedyellow.com/blogs/texasswede/resource/",_
"http://www.texasswede.com/blogfiles/resource/")
	tmp = Replace(tmp,_
"http://www.bleedyellow.com/blogs/texasswede/resource/",_
"http://www.texasswede.com/blogfiles/resource/")
	tmp = Replace(tmp,"/BLOGS_UPLOADED_IMAGES/","/uploaded_images/")
	tmp = Replace(tmp,"´",|"&acute;"|)
	tmp = Replace(tmp,"’","&acute;")
	tmp = Replace(tmp,"“",|&quot;|)
	tmp = Replace(tmp,"”",|&quot;|)
	tmp = Replace(tmp,"…",|"..."|)
	tmp = Replace(tmp,"<wbr>",||)
	tmp = Replace(tmp,"> < ",|>&anp;nbsp;< |) 	
        FixHTML = tmp 
End Function 

Function ProcessBlogEntry(filename As String, localpath As String) As Boolean 	
        Dim session As New NotesSession 
	Dim db As NotesDatabase
        Dim blogentry As NotesDocument 	
        Dim rtitem As NotesRichTextItem
        Dim siteurl As String  	
        Dim html List As String
        Dim tmp As String
        Dim import As Boolean
        Dim titlesection As Boolean
        Dim row As Integer
        Dim currow As Integer  	
        Dim titletext As string
        Dim htmltext As String
        Dim title As String
        Dim posteddate As String
        import = False 	
        titlesection = False
        row = 0 	
        Open localpath For Input As #1 charset="UTF-8"
        Do Until EOF(1)
            Line Input #1, tmp
            If InStr(tmp,|class="entryContentContainer"|) > 0 Then
	 	import = True		
	    End If
	    If import = True Then
		If InStr(LCase(tmp),|<!-- rating -->|) > 0 Then
			import = False		
		End If
 	    End If
	    If InStr(LCase(tmp),|<!-- entry title and info -->|) > 0 Then
		titlesection = True		
	    End If
	    If titlesection = True Then
		If InStr(LCase(tmp),|<!-- user name, date, meta info -->|) > 0 Then
			titlesection = False
		End If
	    End If
	    If titlesection = True Then
		titletext = titletext + tmp
	    End If
	    If InStr(LCase(tmp),|blogsdate.date.localize|) > 0 Then
		posteddate = StrLeft(StrRight(tmp,"localize ("),"));")
	    End If
	    If import = True Then
		row = row + 1
	 	html(CStr(row)) = tmp
	    End If
	Loop
	Close #1

	Set db = session.CurrentDatabase 
	Set blogentry = New NotesDocument(db)
	blogentry.Form = "Blog Entry"
	title = Replace(FullTrim(StrLeft(StrRight(titletext,"<h4>"),"</h4>")),"@amp;quot;",|"|)
	Set rtitem = New NotesRichTextItem(blogentry,"Content") 
	posteddate = Format$(JSMillisecondsToLSDate(CDbl(posteddate)),"mm/dd/yyyy hh:nn") + " GMT"
	siteurl = "http://www.bleedyellow.com/blogs/texasswede/"

	Call blogentry.ReplaceItemValue("Title", title)
	Call blogentry.ReplaceItemvalue("PostedDate", posteddate)
	Call blogentry.ReplaceItemValue("OriginalURL", siteurl + filename)
	currow = 0
	ForAll t In html
		currow = currow + 1
		If InStr(t,	|class="entryContentContainer"|)>0 Then
			' Do nothing				
		Else
			If currow < row-2 Then
				Call rtitem.AppendText(fixhtml(t))
				Call rtitem.AddNewLine(1,true)
			End If
		End If
	End ForAll
	Call blogentry.ComputeWithForm(True,False)
	Call blogentry.Save(True,True)

End Function

Function JSMillisecondsToLSDate(millis As Double) As Variant
	Dim ndt As NotesDateTime
	Dim zoneOffset As Integer
	Dim jsEpochDouble As Double, adjustedEpochDouble As Double, millisDateDouble As Double

	%REM
	JavaScript millisecond values are based on GMT
	but writable LotusScript date/time values are local.
	We need to know the local timezone offset from GMT,
	and for that we need a NotesDateTime object
	with both date and time components
	%END REM

	Set ndt = New NotesDateTime(Now)
	zoneOffset = ndt.TimeZone

	'The JavaScript epoch is midnight (day start) January 1, 1970 GMT
	jsEpochDouble = CDbl(DateNumber(1970,1,1))

	'Adjust epoch to local time
	adjustedEpochDouble = jsEpochDouble - (zoneOffset/24)

	'There are 86400000 milliseconds in a day
	millisDateDouble = adjustedEpochDouble + (millis / 86400000)
	JSMillisecondsToLSDate = CDat(millisDateDouble)
End Function

 

And here is the  agent to export the documents to a CSV file that can be imported into a WordPress blog using the CSV import plugin.

Option Public
Option Declare

Sub Initialize
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim doc As NotesDocument
	Dim filename As String

	filename = "d:\bleedyellow.csv"
	Open filename For Output As #1
	Print #1, |"csv_post_title","csv_post_post",| + _ 
                  |"csv_post_type","csv_post_excerpt",| + _ 
                  |"csv_post_categories","csv_post_tags",| + _ 
                  |"csv_post_date","custom_field_1","custom_field_2"|
	Set db = session.Currentdatabase
	Set view = db.GetView("By Title")
	Set doc = view.GetFirstDocument
	Do Until doc Is Nothing
		Print #1, GetCSV(doc)
		Set doc = view.GetNextDocument(doc)	
	Loop
	Close #1
End Sub

Function GetCSV(doc As NotesDocument) As String
	Dim rtitem As NotesRichTextItem 
	Dim tmp As String
	Dim content As String

	Set rtitem = doc.Getfirstitem("Content")
	content = Replace(FullTrim(rtitem.GetUnformattedText()),|"|,|""|)
	tmp = |"| + Replace(doc.GetItemValue("Title")(0),|"|,|""|) + |",|
	tmp = tmp + |"| + content + |",|
	tmp = tmp + ",,"
	tmp = tmp +|"| + "Old Blog Post" + |",|
	tmp = tmp +|"| + doc.GetItemValue("Tags")(0) + |",|
	tmp = tmp +|"| + doc.GetItemValue("PostedDate")(0) + |",,,|

	GetCSV = tmp
End Function

Welcome to my new blog

Posted on October 13, 2012 by Karl-Henry Martinsson Posted in Blogging, Featured 5 Comments

After having my blog hosted by Lotus911 (later GBS) at bleedyellow.com for almost five years, I have decided to switch blog platform. The main reason is due to limitations in IBM Connections as a blog platform (no anonymous comments and issues for example when trying to embed videos). I decided to go with WordPress as my blog platform, as it is common and widely supported.

Another advantage with a WordPress hosted blog that is that I now can have the blog hosted under my personal domain, as blog.texasswede.com.

Earlier today I imported the existing content to the new blog. I will write about that process in another blog entry shortly. Basically I wrote a couple of Lotusscript agents in Notes and retrieved the existing blog content and then reformatted it for WordPress. As I did not have very many comments, I did not import them, as I decided the amount of work was not worth it. They can be found on my old blog, as I will keep it alive. That way all the links to it from different placs will also continue to work.
I have not verified all old entries, so if you notice anything that need to be fixed, please let me know. One known issue is when I reference another blog entry, the link will currently take you to bleedyellow.com.

Again, a big thanks to GBS who hosted my blog for the last five  years, and who got me into blogging. I had made some attempt prior to 2008, but never got motivated enough. Hopefully the switch to WordPress and the greater possibilities will lead to me blogging more frequently than lately.

Nostalgia

Posted on October 11, 2012 by Karl-Henry Martinsson Posted in Old Blog Post, Programming 1 Comment

I am sure most of you who started programming around the same time that I did (in the first few years of the 1980's) at one point carried something like this in your wallets:

ASCII Table

 

Things to think about when programming in Notes

Posted on October 4, 2012 by Karl-Henry Martinsson Posted in Featured, Formula, Lotusscript, Old Blog Post, Programming Leave a comment

Inspired by some of the posts in the DeveloperWorks forums and on StackOverflow, I thought I would post some more basic concepts and how I handle them. I am not saying my way is the best way, this is just what works for me. I am sure there will be more posts in the future”…”

I will also mention a few other things I noticed while reading the code posted in the forums.

 

Retrieve something that doesn´t exist

The question is how to identify what dates there are no documents created for. This is where lists are very useful. Richard Schwartz answered this question and posted some good code.
Rich suggests to create a list of dates, with each list item having an initial values of false, and then loop through the documents. As each document is processed, the value of the corresponding list item is changed from false to true. You can then go through the list and see which dates still have a value of false, those dates are missing documents.

My version of the same code is to actually delete the list item you have a match for, instead if setting it to true. In the end you have a list of just the items of dates without a corresponding document.

 

Write readable code

This could be a blog entry all by itself. But I notice that much of the code in the DeveloperWorkds forums is hard to read”´”. Partially because any tabs or multiple spaces used for indenting the code is stripped out, but also because the posters don´t write easy-to-read code.

Variable names are often not descriptive:

Dim db1 As NotesDatabase
Dim db2 As NotesDatabase

vs

Dim thisdb As NotesDatabase
Dim nabdb As NotesDatabase

Which one is easier to understand? In my opinion (and I am sure you agree) the second variant. Also function names and other variables should be named so you understand what they do and what kind of data they contain.

Comments are mostly non-existing. It is not that hard to add some comments to the code that explain what the code is doing. But don´t explain every line of actual code (it should be self-explanatory, if variables are named correctly), explain what a particular section of code is intended to do.

Here is a section of code from an agent I wrote earlier this week:

'*** Read PhotoUNID field in LossControl document'*** and build a list of the UNID values in the fieldphotoUNID = lcdoc.GetItemValue("PhotoUNID")(0)If photoUNID<>"" Then '*** Create array of values and put into photolist tmparray = FullTrim(Split(photoUNID,";")) ForAll t in tmparray If t <> "" Then photolist(t) = t End If End ForAll End If

The comments above will help the next person to look at the code to quickly understand what it is intended to do.

 

More on variables

Use Option Declare/Option Explicit. This will find many errors, especially for more inexperienced programmers, where variables are misspelled or missing, something that is a very common reason for posts in the forums.

Another thing that a surprisingly large number of posters seem to struggle with is how to correctly declare variables. I see many cases where several variables are declared on one row, but only the last one has the data type. The author of the code was thinking it would apply to all the variables:

Dim FirstName, LastName, Street, City, PostalCode, State as String

This will declare State as String, but all other variables as Variant. This is not unique for Lotusscript, Visual Basic (on which Lotusscript is based) works the same way.

I always declare each variable on a separate line. This makes it easier to find a particular variable if I am looking for it. I also declare all variables in the beginning of the code/function, again to make it easier to find it in the future. Finally I order the declarations in the same order:

1. Notes UI classes (so they are easy to locate, in case I need to rewrite the code to be used in a server-based agent.

2. Notes backend classes. I always declare them in the order they are being used, as this also is how the classes are structured.

3. Variables and custom classes, in the order they are used.

Here is an example, from the same agent as above:

 Dim session As New NotesSession Dim photodb As NotesDatabase Dim lcdb As NotesDatabase ' LossControl DB Dim lcview As NotesView Dim lccol As NotesViewEntryCollection Dim lcentry As NotesViewEntry Dim lcdoc As NotesDocument Dim photodoc As NotesDocument Dim rtitem As Variant Dim rtnav As NotesRichTextNavigator Dim rtlink As NotesRichTextDocLink  Dim cnt List As Long Dim photoUNID As String Dim unid As String Dim photolist List As String Dim verifiedlist List As String Dim tmparray As Variant Dim photos As String

As you can see, I also put a comment there, to explain what lc stands for.
I also try to use a list for counters, instead of having a number of separate variables. Doing that makes the code easier to read and understand, despite it actually being longer:

 cnt("Total") = lccol.Count cnt("Processed") = 0 cnt("Updated") = 0 cnt("UpdatedPhoto") = 0
 cnt("Processed") = cnt("Processed") + 1 If cnt("Processed") Mod 10 = 0 Then Print cnt("Processed") & " of " & cnt("Total") End If

See how easy that code is to read?

 

Use the Debugger

I see many messages where the poster is getting an error message, or an unexpected result (or no result at all). Sometimes a large chunk of code is posted, but no indicator where the error happens.

It seems like very few (at least of the obviously less experienced programmers) use the debugger at all. In most cases they would quickly find the problem that way, instead of asking why they get “object variable not set” or “type mismatch” errors somewhere in 100 lines of code”…”

Yes, the debugger has limitations, and it could use some new features (like breaking when a particular variable has a specified value or match an expression), but it is a huge help even in the current form.

 

Understand Data Types

Many problems are because the programmer did not understand what data type different functions returns, or even (in some cases) what the different data types means. One poster (I can´t find the post right now) had code like this:

 Dim x As Integer x = 0 x = x + 3.5 MsgBox x

He was the surprised that the message box displayed the value 4… I think understanding data types is a requirement of being a programmer, even if the language you work with is forgiving or don´t require variables to be declared.

 

Analyze the problem

Another common issue I see is that it seems like the programmer just got an assignment and started to write code, without thinking through what the actual process is going to be. He/she often write him/herself into a corner, or is so focused on solving it with existing knowledge (e.g. “has to be @Formula language”), that the difficulty level of the task approaches impossible. Or the code will be extremely convoluted.

Think through the problem, break it down into small problems/steps. Break each of those down into even smaller steps, etc. Finally you have a good specification, and often even pseudo code. It m
ay be that the user requesting the program/functionality (a.k.a. stakeholder) is saying how he want it to be done, but that is really not the stakeholders responsibility. He/she should just explain what the end result should be, and the developer will design the best solution.

I have examples where a manager comes to me and asks for a report “in Excel” of data in a Notes database. That is because the manager in this case was used to working in Excel, and thought of how Excel displays data as the way he wanted it.
I could very easily create a report directly in Notes, displaying exactly the same information. Since I asked what the end result was supposed to be, and how the data was supposed to be used (and by whom), I could avoid Excel altogether and built a pure Notes solution.

This is where experience comes in, things like that is not something you can just pick up at college/university. If you don´t have the analytical/problem solving skills, you will struggle as a programmer. You might be able to write code under strict guidance, or you might even be able to eventually complete the assignment, but it will most probably not be the best/fastest solution, even if the code will work.

Two good blog entries are Separating Programming Sheep from No-Programming Goats (CodingHorror, July 2006) and Why Can´t Programmers.. Program? (CodingHorror, February 2007). Programming consists of problem solving and analytical skills, fundamental skills (like data types, how functions works, recursion different kind of branching/looping), as well as understanding the language and platform you use. If you are missing any of those things, you will probably not be a very good programmer.

 

HCL Ambassador 2020

HCL Ambassador 2020

IBM Champion 2014-2020

Stack Exchange

profile for Karl-Henry Martinsson on Stack Exchange, a network of free, community-driven Q&A sites

Notes/Domino Links

  • Planet Lotus Planet Lotus
  • IBM dW Forums IBM dW Forums
  • StackOverflow StackOverflow

Recent Posts

  • Notes and Domino v12 is here!
  • NTF Needs Your Help
  • Helpful Tools – Ytria EZ Suite (part 2)
  • Busy, busy – But wait: There is help!
  • Semantic UI – An alternative to Bootstrap?

Recent Comments

  • Lotus Script Multi-thread Message Box [SOLVED] – Wanted Solution on ProgressBar class for Lotusscript
  • Viet Nguyen on Keep up with COVID-19 though Domino!
  • Viet Nguyen on Keep up with COVID-19 though Domino!
  • Mark Sullivan on Looking for a HP calculator? Look no further!
  • Lynn He on About This Blog

My Pages

  • How to write better code in Notes

Archives

  • June 2021 (1)
  • April 2021 (2)
  • March 2021 (1)
  • August 2020 (3)
  • July 2020 (2)
  • April 2020 (2)
  • March 2020 (1)
  • December 2019 (2)
  • September 2019 (1)
  • August 2019 (2)
  • July 2019 (2)
  • June 2019 (3)
  • April 2019 (2)
  • December 2018 (1)
  • November 2018 (1)
  • October 2018 (5)
  • August 2018 (2)
  • July 2018 (3)
  • June 2018 (2)
  • May 2018 (1)
  • April 2018 (2)
  • March 2018 (1)
  • February 2018 (2)
  • January 2018 (4)
  • December 2017 (3)
  • November 2017 (2)
  • October 2017 (2)
  • September 2017 (1)
  • August 2017 (2)
  • July 2017 (6)
  • May 2017 (4)
  • February 2017 (1)
  • January 2017 (2)
  • December 2016 (2)
  • October 2016 (3)
  • September 2016 (4)
  • August 2016 (1)
  • July 2016 (2)
  • June 2016 (2)
  • May 2016 (3)
  • April 2016 (1)
  • March 2016 (4)
  • February 2016 (2)
  • January 2016 (4)
  • December 2015 (3)
  • November 2015 (2)
  • October 2015 (1)
  • September 2015 (2)
  • August 2015 (1)
  • July 2015 (5)
  • June 2015 (2)
  • April 2015 (2)
  • March 2015 (3)
  • February 2015 (2)
  • January 2015 (10)
  • December 2014 (1)
  • November 2014 (3)
  • October 2014 (3)
  • September 2014 (13)
  • August 2014 (6)
  • July 2014 (5)
  • May 2014 (3)
  • March 2014 (2)
  • January 2014 (10)
  • December 2013 (5)
  • November 2013 (2)
  • October 2013 (5)
  • September 2013 (4)
  • August 2013 (7)
  • July 2013 (3)
  • June 2013 (1)
  • May 2013 (4)
  • April 2013 (7)
  • March 2013 (8)
  • February 2013 (9)
  • January 2013 (5)
  • December 2012 (7)
  • November 2012 (13)
  • October 2012 (10)
  • September 2012 (2)
  • August 2012 (1)
  • July 2012 (1)
  • June 2012 (3)
  • May 2012 (11)
  • April 2012 (3)
  • March 2012 (2)
  • February 2012 (5)
  • January 2012 (14)
  • December 2011 (4)
  • November 2011 (7)
  • October 2011 (8)
  • August 2011 (4)
  • July 2011 (1)
  • June 2011 (2)
  • May 2011 (4)
  • April 2011 (4)
  • March 2011 (7)
  • February 2011 (5)
  • January 2011 (17)
  • December 2010 (9)
  • November 2010 (21)
  • October 2010 (4)
  • September 2010 (2)
  • July 2010 (3)
  • June 2010 (2)
  • May 2010 (3)
  • April 2010 (8)
  • March 2010 (3)
  • January 2010 (5)
  • November 2009 (4)
  • October 2009 (7)
  • September 2009 (1)
  • August 2009 (7)
  • July 2009 (1)
  • June 2009 (4)
  • May 2009 (1)
  • April 2009 (1)
  • February 2009 (1)
  • January 2009 (3)
  • December 2008 (1)
  • November 2008 (1)
  • October 2008 (7)
  • September 2008 (7)
  • August 2008 (6)
  • July 2008 (5)
  • June 2008 (2)
  • May 2008 (5)
  • April 2008 (4)
  • March 2008 (11)
  • February 2008 (10)
  • January 2008 (8)

Categories

  • AppDev (9)
  • Blogging (11)
    • WordPress (5)
  • Design (5)
    • Graphics (1)
    • UI/UX (2)
  • Featured (5)
  • Financial (2)
  • Food (5)
    • Baking (3)
    • Cooking (3)
  • Generic (11)
  • History (5)
  • Hobbies (10)
    • LEGO (4)
    • Photography (4)
  • Humor (1)
  • IBM/Lotus (175)
    • #Domino2025 (14)
    • #DominoForever (8)
    • #IBMChampion (46)
    • Administration (7)
    • Cloud (7)
    • CollabSphere (8)
    • Community (47)
    • Connect (33)
    • ConnectED (12)
    • Connections (3)
    • HCL (12)
    • HCL Master (1)
    • IBM Think (1)
    • Lotusphere (46)
    • MWLUG (25)
    • Notes/Domino (97)
      • Domino 11 (7)
    • Sametime (8)
    • Verse (14)
    • Volt (2)
    • Watson (6)
  • Life (8)
  • Microsoft (7)
    • .NET (2)
    • C# (1)
    • Visual Studio (1)
  • Movies (3)
  • Old Blog Post (259)
  • Personal (23)
  • Programming (83)
    • App Modernization (11)
    • Formula (4)
    • Lotusscript (46)
    • NetSuite (4)
      • SuiteScript (3)
    • node.js (4)
    • XPages (4)
  • Reviews (9)
  • Sci-Fi (4)
  • Software (24)
    • Flight Simulator (2)
    • Games (4)
    • Open Source (2)
    • Utilities (6)
  • Technology (37)
    • Aviation (3)
    • Calculators (2)
    • Computers (6)
    • Gadgets (7)
    • Mobile Phones (7)
    • Science (3)
    • Tablets (2)
  • Travel (6)
    • Texas (2)
    • United States (1)
  • Uncategorized (15)
  • Web Development (50)
    • Frameworks (23)
      • Bootstrap (14)
    • HTML/CSS (12)
    • Javascript (32)
      • jQuery (23)

Administration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Tracking

Creeper
MediaCreeper
  • Family Pictures
© TexasSwede 2008-2014