Obscuring threshold concepts

Threshold concepts (TC) discussed in papers like Eckerdal et al. (2007) and others. The existence and the use for threshold concepts in Computer Science Education are open for debate.

Though in programming you often feel that after struggling with understanding a construction you suddenly get an insight of how things work and you see things in another light and suddenly you just get a flow and can solve your tasks better than before. This could for example be understanding some part of Object oriented programming better.

Sourva (2010) and others extend this thoughts and introduces a liminal space that you as a learner occupies, perhaps unknowing, while trying to overcome a threshold. In this interesting article he also introduces Fundamental ideas (FI) that runs threadlike across and beyond a discipline.  Examples here according to Sourva (2010) is state and abstraction that at least when it comes to state it is perhaps not a threshold in the same sense as his examples of threshold concepts like program dynamics, information hiding and object interaction. I can’t really see the distinction between the fundamental ideas  and the threshold. For quoting Sourva (2010) he says about program dynamics that

“A crucial distinction between the existence of a programs code and its existence as a dynamic execution-time entity within a computer. Code is tangible and its existence is really easy to perceive. The existence of the latter aspect of a program, which I call program dynamics, is much less so.”  

This becomes quite obscure to me because as he describes program dynamics it is really dependant on abstractions and the concept of the programs state. I would think that there are thresholds that you have to pass and after you passed them there is no turning back, you can’t unlearn them. It is like when Neo in Matrix takes the red pill, there is for him and for a programmer no turning back once you understood OOP. I the article Sourva (2010) also discuss what he calls transliminal concepts as smaller TC’s for example concerning the big program dynamics TC there would be function calls, recursion, instantiation, loops as transliminal concepts parts that are more concrete and less generic than a TC.

I think that for a teacher to have as a goal to guide the students to pass these thresholds is great but also to think that they are to my belief probably TC’s are very different for each individual. I would guess that many students would say OOP is a TC but I would also suspect that they will mean different things with that answer. I would also argue that there are TC’s that you can do without like pointers. To quote the frequent programmers c++ question “Do you mean the object or the pointer”. When teaching Java I try to do that initially without any talk of pointers I say that they are referring to the same object, only the command line nerd have problems understanding that. In real life there is a rat in the house there are not more than one rat because all members of the family looks at the rat. The cloning that is what is weird in comparison to real life.

What I do think hinders students to move through a TC is when those transliminal concepts laying out there on the road to the threshold or beyond is illogical as those I pointed out in on Illogical stuff. Then you really confuse a student and it is better to guide the student around those transliminal traps that can lead you totally wrong.

To take an example when understanding objects and iterating trough them. Using an iterator pattern and a foreach construction like this is easy to understand and not as techie as using a classic forloop.

1 ArrayList<Shoe> shoes = new ArrayList<Shoe>(); 2 for (Shoe shoe : shoes) { 3 shoe.setSize(8); 4 } 5 6 ArrayList<String> strings = new ArrayList<String>();; 7 for (String s: strings){ 8 s = "Change all"; 9 }

It is very understandable that the shoes are collected one after each other and placed in the variable shoe. After that the size is changed for all shoes to 8. What becomes confusing is if you have an ArrayList of String were in the example above the value of the Strings in the array is not changed, The same holds for Integer, Double etc.

This is more or less obvious if you have understood that String, Integer are Immutable objects, but to understand this as a novice programmer is not an easy task. This is again an example of a concept in Java that is really hard to get around since String’s are used extensively in many examples you get across on the net. So moving from Java to languages that don’t have this problem could be an idea but at the same time since Java-like languages are an Industry standard.

References
Jonas Boustedt , Anna Eckerdal , Robert McCartney , Jan Erik Moström , Mark Ratcliffe , Kate Sanders , Carol Zander, Threshold concepts in computer science: do they exist and are they useful?, ACM SIGCSE Bulletin, v.39 n.1, March 2007 [
Juha Sorva, Reflections on threshold concepts in computer programming and beyond, Proceedings of the 10th Koli Calling International Conference on Computing Education Research, p.21-30, October 28-31, 2010, Koli, Finland

Posted in Uncategorized | Leave a comment

On illogical stuff like int, wrapper classes, Immutable types when teaching programming in Java.

Moving from procedural programming with Java and primitive datatypes like int to the object oriented arena when teaching programming is like travelling from an mathematical view of the word towards a more real world analogy. In my experience there are quite a few students that face a greater challenged learning procedural programming than Object Oriented Programming. One reason for this is mixing if concepts and that is for example exemplified when looking at primitive data types and wrapper classes in Java and another reason is that procedural programming resembles more to school math than Object oriented programming.

The primitive datatype int represents more or less exactly integers the way it is thought in the math sessions in school. The wrapper class Integer is then a hybrid that is hard to understand from an novice OOP perspective and from that high-school math perspective. There are of course logical explanations for the wrapper classes (Oracle, Wrapper Classes) but also criticism (Alpert, 1998). The non primitive class Integer is there only to bridge the gap between Procedural programming and OOP. The reasons given are generally polymorphism, ability to assign null to a object and the ability to have integers in collections. For example the wrapper class Integer is used when you want to use numbers in a List and or using the sorting capabilities or the possibility to expand the List at runtime. (The List class does not take primitive data types and then you have to use the proper object Integer in that class).

Since java 1.5 boxing (Oracle,  Boxing and Unboxing) together with generics the problem is less than before but from a novice learner perspective it is hard to grasp the difference between the value and the reference to the object/value.  Like in example 1 where it is an pedagogical challenge to explain why (l == k) returns false. This of course also has to do with the fact that Java hides the use of pointers more that C++.

1 int i = 3; 2 int j = 3; 3 4 Integer k = new Integer(3); 5 Integer l = new Integer(3); 6 7 //Comparing primitive variables 8 if (i == j){ 9 //True 10 } 11 12 //Comparison on wrapper classes (Immutable) 13 if (l == k){ 14 //False 15 } 16 if (l.equals(k)){ 17 //True 18 }

Example 1. The comparisons in the first case row 8 – 10 is a comparison between two primitive datatypes int and the result is as expected. From row 12 to 18 the wrapper class Integer is used and when the instances are created by using new (instead of creating the instances with boxing),  it is then two different objects and therefore the references are different as seen when using == in the comparison, although the content is the same as seen when using the equals method as you are supposed to when comparing objects. 

From the OOP part there is the String class that makes the leap to the Procedural programming arena.  Strings are also immutable and there are of course good logic for it to be that way (JavaRevisited, 2010). But from learner perspective explaining why the first (s1 == s2) is true but not (s2 == s3) in the example bellow is quite a challenge.

1 String s1; 2 String s2; 3 String s3; 4 s1 = new String("Test"); 5 s2 = "Test"; 6 s3 = "Test"; 7 if (s1 == s2){ //False 8 //.. 9 } 10 if (s1.equals(s2)){ //True 11 //.. 12 } 13 if (s2 == s3){ //True 14 //.. 15 } 16 if (s2.equals(s3)){ //True 17 //... 18 }

Example 2: String literals are reference datatypes but are also immutable, this means that they fall somewhere in-between primitive datatypes and reference datatypes. The pedagogical challenge for explaining this is illustrated when comparing row 7 and 13 in this example.

The examples above is only the top of the iceberg and you can construct really challenging examples based on this dichotomy. The way I normally go at it when teaching in this area i more or less avoiding the problem. Of course it is not totally possible because Arrays are unavoidable in beginners road to deepening there in this area. It is hard to avoid arrays because they are very common in examples on internet and also because Lists don’t, as stated earlier, take primitive types. Arrays come in handy when learning for – loops and it is essential construction for understanding how you can repeat programming lines a set number of times like in example 3. The declaration and instantiation of the array in example 3 (int[]) doesn’t follow standards in the rest of the java language which also adds to the confusion when working with collections either containing primitive types like int or referece types.

1 int[] myIntArray; 2 myIntArray = new int[100]; 3 for (int i = 0; i < myIntArray.length; i = i +1){ 4 myIntArray[i] = 10; 5 }

Example 3: Using an array containing int in a straightforward procedural manner.

When you want to do more complex things like sorting or handling collections of previous unknown size Lists are needed. There is then a demand for wrapper classes if you want to handle integers in the List. An example of this can be seen in the example bellow.

1 ArrayList<Integer> myIntegerList; 2 myIntegerList = new ArrayList<Integer>(); 3 for (int i = 0; i < 100; i++) { 4 myIntegerList.add(new Integer(10)); 5 } 6 //All 100 elements have the value 10 7 for (Integer integer : myIntegerList) { 8 integer = 12; 9 } 10 //Here all elements still have the value 10 !!!

Example 4: Using a list for storing integers, since they are immutable the value cannot be changed the way shown above, this has to be done by using the set() method of the list.

Example 4 points out another illogical border problem if you compare the example above with example 5 one could expect that changing the value to 12 would change the value in both examples.  

1 ArrayList<A> myAList; 2 myAList = new ArrayList<A>(); 3 for (int i = 0; i < 100; i++) { 4 myAList.add(new A()); 5 } 6 //All 100 elements have the value 10 set to the variable i 7 for (A a : myAList) { 8 a.setI(12); 9 } 10 //All 100 elements have the value 12 set to the variable i 11 12 //Where A is 13 public class A{ 14 private int i =10; 15 public int getI() { 16 return i; 17 } 18 public void setI(int i) { 19 this.i = i; 20 } 21 }

Example 5: Populating an ArrayList and iterating the collection and changing the value of the instance variable in A. Compare this behaviour with example 4.

I would like to avoid for – loops when iteration arrays and instead work with an iterable pattern  but as the example above shows it is not consistent. Iterating collection is really a nicer construction than for-loops and very understandable for novice users.

Conclusion
This post points out the dichotomy between procedural programming and object oriented programming and the confusion that introduces to students from an teacher/learner perspective. Many programming languages have this division and it also appears in the real world between a more mathematical viewpoint and a more holistic way of seeing the world. I do therefor think that we should address the problem, not by using illogical overlapping constructions like wrapper classis or Immutable variables, but instead allow those contradictions to exists side by side as two ways of describing the world. Avoiding these language constructions when learning programing gives you a confidence and a possibility to understand and use those constructions at a later time when they make sense. After all understanding how a bike works is a lot different from being able to ride one (but not as fun).

References
Oracle, java Autoboxing, https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html
Wrapper classes
https://docs.oracle.com/javase/tutorial/java/data/numberclasses.html
Sherman R. Alpert, 
http://www.research.ibm.com/people/a/alpert/ptch/ptch.html
Javarevisited,
http://javarevisited.blogspot.se/2010/10/why-string-is-immutable-in-java.html

Posted in Java, Learning programming | Tagged , , , | Leave a comment

On i++; and other disturbances

Programmers as other people has habits and preferences that often are defended in high pitch when questioned. There are many discussions on different programming topics on the net and it often boils down to a performance discussion. To me that is like when the economy is brought into a discussion, it effectively puts a lid on everything when someone with enough technical depth convinces everyone that we gain a nanosecond somewhere and that we therefore should favour one solution or one language over another. I often say that in most cases it is better value in buying more computing power than a memory optimized solution by an expensive expert. 

One of these areas are for example incrementing a variable in some of the major programming languages. This  can be done in many ways, my principle is always to sacrifice some extra characters and performance for readability and to avoid error prone code. Especially when teaching but also when sharing code with others. There is of course always the argument that as a learner you have to be able to read other peoples code but that doesn’t imply that I have to add to the confusion. By being clear in what I think is good coding style my students hopefully chooses code that are well written and structured when the look for example code on the net. 

As an example even experienced programmers have to think twice when asked for the value of x and y after the lines in figure 1 and 2 are executed:

Figure 1: Making simple things hard, here the value of x is 4 and y is 5 after the execution.

Figure 2: Making simple things hard, here the value of x and y is 5 after the execution.

Figure 3: Figure 2 could be written like this.

My feeling is that many programmers and teachers want to show how skilled they are by writing clever code, but then remember code is read many more times than it is written. Like in natural languages were the goal hopefully is to speak so the receiver understands it we have to write our code for other readers. The tradition in the programming area is that the receiver is the computer but this is has changed the last years when we share so much code over the net with others.

So nowadays we tend to write code not only for the computer but for other programmers and designers. So what we are facing now is the transformation of programming languages into a more public arena, and that will of course favour those who write understandable code and the languages that are more understandable. It is like dialects in natural languages, it is not a favour to speak a dialect than no one understands outside your community (that is if you want to be recognised in your area outside your hometown).

Another example of questionable coding habits comes from Douglas Crockford (Crockford 2011) argues out of security and introducing bugs for using:

instead of

and that is of course an improvement but still the confusion for a novice that the two character combination are used for equality and conditional operators. like ‘==’, ‘>=’ so better would be to write

where we minimise the possibility for misunderstanding.

Except the use of ‘=’ it is clearly more readable. Also the use of static code analyse tools like lint can be used as an aid to remove confusing language constructions and this will further speed up the converging  in computer languages.

There are a massive amount of new programming languages coming up not to mention the old ones still in use. Is the solution to come up with a new that address some problem in an older language? Very often i find that new languages are more reactions than a real novel thinking, we probably has to come up with new paradigms and they will and can probably build on one of the popular languages we have today. The same way that modern programming languages build on intermediate code and machine code.  Langpop.com gives an indication of the most popular programming languages and the overwhelming majority is standard languages so there are really two paths to walk here if we want to change this conservative market.

Either invent or find that new language or build on the ones that dominates the market so they become the machine code of tomorrow. 

image

Figure 4: Language popularity from http://Langpop.com

In figure 5 the most popular languages for teaching programming in the US are plotted. . Also that python is the number 1 is interesting, does Python address many of our languages issues?

Figure 5: Most popular teaching languages in top- ranked U.S. Departments.

 

Crockford Douglas (2011) Crockford on JavaScript – Part 5: The end of All Things https://www.youtube.com/watch?v=47Ceot8yqeI 1:09 into the video.

Posted in Learning programming, Programming | Tagged | Leave a comment

Equality = Assignment

Why do we use equality sign in programming

The assignment operator ‘=’ is one of the first unnecessary obstacle for a novice learner since most students spent quite a few years using the equality sign ‘=’ in math. Traditionally in math it is used like this:

x = 3

This means as you all know that x has the value 3 this also to many students signals that you solved the equation or found the answer. Also in the part of the world were my students come from we read from left to right. So like this:

f(x) = x^2 + 3x + 19\\f(3) = 9 + 9 + 19 = 37

To teach someone programming, after spending many years struggling with the math, then we say: in programming equality sign means something different than assignment and travels from right to left.
Ok the student says that is no big deal or?
It is a huge difference, to begin with in programming ‘=’ has a opposite direction meaning when writing

x = 3;

that x is assigned the value 3 and that is not the same as x has the value 3.

Like this what would a novice programmer do with this?

x = x + 3;

A novice student would solve the equation
x = x + 3
with the result that 3 equals 0 and that is obviously wrong.

It gets worse because we are used to have an equality sign in equations means that everything on the different sides weighs the same and that we can solve the equation like this.

x^2-2x=3\\x^2-2x -3=0\\\left\{\begin{matrix} x_{1}=1+2=3\\ \\ x_{2}=1-2=-1 \end{matrix}\right.\\

Then to further complicate things the equality sign in most popular programming languages is typed ‘==’ so this is a true statement
3 == 3
but not
x=3
I really don’t blame students for being confused so why is it like this in most popular programming languages ( Java, c#, JavaScript, php, c++, c)?  A language like Pascal when that was popular used := as a denote for an left arrow <- some of this older languages also used = as equality which make a lot of sense. But today <= means less or equal in most modern languages to further complicate things.

So why, was it the c-peoples extreme fight for minimalistic writing and not have any unnecessary characters and to save one valuable byte somewhere on some ancient floppy disc? Is it this that still puts eager learners of in their first contact with programming? Or is it the club of programmers fighting of those who doesn’t know how write code.

Why introduce right to left (RTL) in programming where does that come from when we are thought to read from left to right (LTR) from preschool?

Then it becomes more complicated when you mix imperative programming programming with Object Oriented programming (OOP) you write like this (example from Java written for Android devices).

1 public void addTeacher(Teacher t) { 2 boolean found = false; 3 if (t!=null){ 4 for (Teacher t2 : myTeachers) { 5 if(t.getUserID().equals(t2.getUserID())){ //Found 6 found = true; 7 } 8 } 9 if (!found){ 10 myTeachers.add(t); 11 } 12 } 13 }

In this example row 6 is read RTL but row 10 LTR and row 5 and 2 is really Bi-directional which adds to the complexity, the code has to be read more as a picture and you know that it takes a lot of effort if you ever spent an afternoon tutoring students with their assignments. And then I don’t speak about the API learning overhead on systems like Android. When the things you want to do are really simple and you end up with being caught in abstracting many objects and simulating their behaviour in your head.

Raising this to a more principal level (Victor 2012) this denotation fails on so many levels like readability and metaphors not to mention that to be a programmer you have to think like a computer. The programming guru Alan Perlis early stated that “To understand a program you must become both the machine and the program.” Then he was born 1922 and at the time he was in his most vivid days I am sure you needed to understand a computer to be a good programmer. But isn’t it time to leave that?

Are OOP the answer here? Sorry no that is only another implementation of another Alan Perlis quote “A programming language is low level when its programs require attention to the irrelevant.”  Example here make a simple Android app showing a RSS feed in less than one hour from scratch without any design requirements.

So were do we go from here being pragmatic and recognising that it is as bad as it is, how do we avoid to put students of when teaching them programming? The answer is to make the best out of is and handle it as a flaw in the language as such like the use of the word “Hot” when describing the food in a restaurant.

References

Victor Bret (2012), Learnable Programming, http://worrydream.com/LearnableProgramming/ (2014-10-22)

Posted in Programming | Tagged , , | Leave a comment

UML for Pfi2

We will use a UML-tool from Visual Paradigm for the course. Register and download Community Edition. You will receive your licence key via mail, point to that file when requested during installation.

We will use the tool as a standalone product during the course and not the version integrated with Eclipse (The integrated version is not available in on MAC). So in your minimal installation just select Visual Paradigm for UML 8.0 se below….

image

Then just fire up and create som Class diagrams and Use Case diagrams which are the to diagram types we will use in this introduction course.

More information and inspiration around UML can be found here:
http://www.sparxsystems.com/resources/tutorial/logical_model.html 
http://www.sparxsystems.com/resources/tutorial/use_case_model.html 
http://edn.embarcadero.com/article/31863

Books to those of you who want more and deeper knowledge……..
Fowler, Martin: UML Distilled Third Edition – A Brief Guide to the Standard Object Modeling Language (2003)
Brett McLaughlin, Gary Pollice, David West: Head First Object-Oriented Analysis and Design (Read perhaps Head First Java before this book)

Posted in pfi2 | Tagged , , , | Leave a comment

Setup for Eclipse, WindowBuilder and EGit för Pfi2

For er som följer pfi2 kursen…. detta är bra förberedelse inför första föreläsningen.
Beväpna er med MYCKET TÅLAMOD innan ni börjar.

1::::Installera Eclipse Helios::::
Hämta Eclipse IDE for Java Developers, 98 MB
Packa upp o kopierar till lämpligt ställe som Program folder beroende på ditt operativsystem.
Starta Eclipse genom att dubbelklicka filen eclipse.exe Smile lägg gärna till som shortcut.

image

2::::Google WindowBuilder::::
Installera WindowBuilder för Eclipse 3.6 Helios
Gå till
http://code.google.com/intl/sv-SE/javadevtools/wbpro/
för att se på en manual som nästan stämmer…..
OBS: Klistra in länken
http://dl.google.com/eclipse/inst/d2wbpro/latest/3.6
i stället för den som anges manualen vi “Paste update Url here”.
(Svär lite)
Swing Designer
Du kan installera hela paketet eller endast välja Swing designer om du inte vill ha en massa val som vi inte använder i denna kursen….
3:::::Eclipse & WindowBuilder Test:::::
Starta Eclipse: Tryck på WorkBench
Skapa nytt Java projekt
File>New>Java Project
Ge det ett namn:
<Finish>
Skapa ett fönster JFrame i det nya projektet
New>Other>WindowBuilder>SwingDesigner>JFrame

Swing designer2
<Next>
Package tex: se.mah.k3
Name tex: TryItOut
Tryck den lilla gröna pilen run.. Och ett ett fönster (JFrame) skall komma upp.
Lek sen runt lite med DesignVyn på Filen TryItOut.java

TryItOut

4:::Installera EGit versionshantering + hämta exempel skrivna av:
!Andreas.:::

Inifrån Eclipse
Help>Eclipse Marketplace>Sök EGit samt installera
EGit – Git Team Provider
Installera ok……
—-
Testa Git genom att hämta Andreas projekt.
Inifrån Eclipse
File Import>Git> Projects from Git
<Clone>
Pejsta in
https://github.com/agoransson/pfi2_examples.git 
som URI
<Next><Finish>
Markera raden som börjar Pfi2_examples
select Git
<Next>
Import existing projects:
Välj att hämta alla projekt.
select proj

<Next> <Finish>Därefter skall alla agoranssons projekt finnas på plats bland dina projekt.
Provkör något av projekten välj att köra dem som Java Application om du blir tillfrågad.

Sajter där du kan läsa mer.
Eclipse: Http://www.eclipse.org
WindowBuilder: http://code.google.com/intl/sv-SE/javadevtools/wbpro/
EGit: http://www.eclipse.org/egit/
Vi kopplar EGit till GitHub  https://github.com/ som är en gratistjänst för koddelning mm. Lämpligen lägger ni upp egna repositories där senare så att ni kan dela kod med varandra. Beväpna er med Lite Ännu MER tålamod för att bemästra GitHub och EGit men det är det värt. Om du inte betalar för ditt utrymme på GitHub är all kod man skriver publik men så länge ni inte har gjort större genombrott så kan ni kanske leva med det.

Surfa på agoranssons kod här: https://github.com/agoransson/pfi2_examples

LYCKA till
mvh
/L

Posted in pfi2 | 2 Comments

Application pool account in MOSS

Starting this new day with assigning a new application pool account to the PKS site.´
Like a lot of things with SharePoint it can be hard to know were to do things, in this case I thought I had to configure the application pool account by hand and that process took me at least 3h.
Anyhow I learned how to get into a hidden SQL database, which is knowledge I probably will never ever use again.

Assigning a new application pool account is done like this:
So, if you need to change the identity of who runs your application pool just go to Central Administration, Operations, Service Accounts.  Select the application, select the application pool, and then change the username and password.  Simple.”

ref:
How to assign a new application pool account.

Hidden databases:

Entering a hidden database named \microsoft##SSEE. You access it from management studio by giving this server name  \\.\pipe\mssql$microsoft##ssee\sql\query .
(What I wonder is how do people find things like this out.)

Posted in SharePoint | Tagged , | Leave a comment

Unknown server tag ‘asp:ScriptManager’

 

While installing PKS I get this error
“Unknown server tag ‘asp:ScriptManager’.”

This can beautifully be solved with this solution:

The Lazy way
Ajax the lazy way

This guy seems to been working with stuff related to our work:
PKS mutiserver etc

Posted in Uncategorized | Leave a comment

C# and Arduino reading port info

If you like me want to use the Arduino for some simple input from the real word here is a small VS 2008 C# project that reads port 12 on the Arduino and checks if it is 0 or 1. Before you can run this you have to change the variable in Constant class so it point to the Serial(USB) port that you use fx (I haven’t investigated the possibility to identify the Arduino automatically.

public static string SERIAL_PORT_FOR_ARDUINO = "COM18";

The project is built following the observer pattern.
So to use it let one of your classes (the observer) implement DeviceListener and declare
these variables in that class:

private SerialPortDevice mySerialDevice = new SerialPortDevice();
private ArduinoDevice myArduinoDevice=null;

private SerialPortDevice mySerialDevice = new SerialPortDevice();
private ArduinoDevice myArduinoDevice=null;

And then register as a observer to the SerialPortDevice in the constructor like this:

mySerialDevice.registerDeviceListener(this);

Then implement the observer-method update which delivers a Status object with all info. If there is a Arduino on some port register as listener to this device.
Something like this:

#region DeviceListener Observer method
        public void update(Status status)
        {
            //If the update is from USBDevice and Arduino Connected
            if (status.SerialPort&&status.arduinoConnected){
                if (myArduinoDevice == null)
                {
                    myArduinoDevice = new ArduinoDevice();//Ok found arduino
                    myArduinoDevice.registerDeviceListener(this);//register as listener
                }
                setStatus("Arduino Connected");
                setPortMessage(status.ActiveSerialPorts);//Specific to this project use your own action here.
            }
            //if update from USBDevice and Arduino not connected
            if (status.SerialPort && !status.arduinoConnected)
            {
                if (myArduinoDevice != null)
                {
                    myArduinoDevice.closePort();
                    myArduinoDevice.removeDeviceListener(this);//remove arduino listener
                    myArduinoDevice = null;
                }
                setStatus("Arduino disconnected");
                setPortMessage(status.ActiveSerialPorts);//Specific to this project use your own action here.
            }
            //if some error in connection
            if (!status.SerialPort && !status.arduinoConnected)
            {
                if (myArduinoDevice != null)
                {
                    myArduinoDevice.closePort();
                    myArduinoDevice = null;
                }
                setStatus("Arduino connection problem");//Specific to this project use your own action here.
            }
            //new data
            if (status.newDataRead)
            {
                nbrOfRead++;
                setNewMessage("Data from pin 12: " + status.port12status + " reading the " + nbrOfRead + " time.");//Specific to this project use your own action here.
            }
        }
        #endregion

for this example the Arduincode looks looks this:

//testcode for the ArduinoAPI test project
int ledPin = 12;
void setup()
{
  Serial.begin(9600);
  pinMode(ledPin,INPUT);
  digitalWrite(ledPin,HIGH);
}
void loop(){
    Serial.print(digitalRead(12));
    delay(1000);
}

The visual studio 2008 .NET 2.0 project is available here.

 http://cid-71f17981a0cae98b.office.live.com/embedicon.aspx/.Public/ArduinoAPI.zip

Posted in Uncategorized | Leave a comment

Application pool account in MOSS

Starting this new day with assigning a new application pool account to the PKS site.´
Like a lot of things with SharePoint it can be hard to know were to do things, in this case I thought I had to configure the application pool account by hand and that process took me at least 3h.
Anyhow I learned how to get into a hidden SQL database, which is knowledge I probably will never ever use again.

Assigning a new application pool account is done like this:
So, if you need to change the identity of who runs your application pool just go to Central Administration, Operations, Service Accounts.  Select the application, select the application pool, and then change the username and password.  Simple.”

But is it realy that simple in my case on a domain controller I had to give the user access to the ssp user accounts manually. I got this error:

A runtime exception was detected. Details follow.
Message: ‘xxxl’ is not a valid Windows NT name. Give the complete name: <domain\username>

ref:
How to assign a new application pool account.

Posted in Uncategorized | Leave a comment