 Welcome back, in the previous segment we discussed the math representation of the circuits that were designed and we also discussed how we solve those circuits. Now we are going to talk about what kinds of extensions might be possible. So there are some obvious things that could be done, we could improve the appearance. So we should really be putting the standard symbols of resistances and current sources. And maybe we should not really be using the shell window at all, everything should happen on the canvas. So the final values should be shown on the canvas and in fact the user should be asked to type directly on the canvas as well. And if the user places a node but then later on does not like the position, maybe it becomes too cluttered or something like that, then the user should be allowed to drag the components to adjust this visual appearance. So this can be done and the primitives you need for it are discussed in chapter 20 of the book. And here is something that you might have seen happen with nice CAD programs. So for example if I have say vertex node 0 and node 1 over here and suppose I click on node 0 then a good program will change the color of this node to indicate that oh you just clicked on it. So that way visually there is a queue given to you which tells you where you are and that makes it easier to use the program. That is not hard, it is just a matter of detail and you can do it even now. And I certainly suggest that this is one of the extensions that you should try out. So basically if I am selecting this node in order to add a conductance I am first going to click on it, then I am going to click on this and the color should change but the color should go back to the original colors once this entire operation has been finished. So this is a good exercise for you. Other functionality could be also added. So if several components are connected across the same pair of nodes then we need to draw them far apart. Right now we are drawing them on a straight line but maybe if a second component gets put we need to put it on the curve or maybe we need to put it on a line like that or maybe we need to let the user decide what this line ought to be. But whatever it is that is something that needs some work and it needs some worrying about geometry and things like that. Then right now our code is modifying a and b in matrep directly while we are solving. So probably the right thing to do is to make a copy of it and then modify the copy of it and keep the values of a and b consistent with what we said when we defined a and b. In particular aii should equal the sum of the conductances leaving i and we should just maintain a and b to be that. So and we could allow other components for example capacitors but with capacitors the solution is time dependent. So the capacitor gets charged and as a result the value is different at different times. So what we might have to do is we might have to show waveforms. So you could say first solve and then maybe you could click on that component and that should pop up a window in which you can see the voltage waveform or maybe not I do not really mean a window but just a rectangle should be there on the side inside which that the voltage waveform should be shown. And a very important part of professional programs is that they gracefully tolerate errors. So if I am expecting to click on two different nodes in order to insert a conductance our program as it stands will probably do something wrong if I just happen to click on the same node twice. So what should happen is somehow the program should indicate to me that oh you have made a mistake and please correct it. So similarly for typing also if I say type a non-numerical value and a numerical value is expected the program should check that and tell me. So we have finished the discussion of this graphics editor and solver and what are the conclusions? Well graphical user interfaces are very convenient and they are actually not too hard to develop. So our code is interesting and some comments are worth making about it. So our code is separating the various concerns quite well. So what do I mean by this? Well the class math rep keeps track of the mathematical representation. The class canvas content manages the visual appearance what happens on the canvas and the main program has sort of the overall control. So if I want to think about a complex system and you can get systems which are much more complex than our editor I do want this kind of separation of concerns. So I want the overall control to be in one place, the canvas management to be in another place and the math representation to be in another place because if everything is cluttered together a reader will get confused. So in fact in our program that seems to have been managed quite nicely. And the way it has been managed is because we have a hierarchy of objects. So the math rep should contain the matrix and the vector. The matrix and vector should not be a part of the main program. So those are low level details and the main program is meant to explain or is meant to talk about how the overall control, how overall control flows inside our program. And so this would be the matrix and vector would be a fairly low level detail which would just confuse the issues if you put that matrix and the vector inside our main program. The canvas content contains nodes and if you want you can also put in the edge data structures. Right now we do not have any edge data structures because visually we create an edge and it is imprinted on the screen and subsequently there is no question of modifying it. But as we said in the extensions you may want to modify the edge value. So say you might say that look I entered a 5 over 5 for this conductance but no, no I really want to change it to 6 so in this case we will need some visual representation of our edge as well and that for example should go into the canvas content. Just as we had a node array there you should also have an edge array over there. And one more principle is that you have a hierarchy of objects and from one member of the hierarchy you really should not reach out into the sub-objects in another hierarchy because then that becomes confusing. So main program knows about canvas content and Mathrep. So main program should invoke member functions in canvas content and Mathrep. The main program should not directly access the members in data members in canvas content and furthermore say for example the canvas content had this, had a member called node ptr and that contained elements of the form node and it would be wrong for the main program to directly access the members of this node ptr. So what should happen is that there should be a member function at the level of canvas content which Math, which our main program is allowed to access but not the details inside canvas content. So again I should perhaps explain this pictorially. So you have the main program, you have canvas content, you have Mathrep and inside it there is something, inside it there is something and inside that there is something. So main has a specific set of member functions that the designer of CC should expose. So main should only call these member functions. It should not reach out and touch things inside CC and certainly not touch things which are deep inside CC because then what your program is trying to do becomes very, very unclear. So keep things simple, keep things at this level which is that there are member functions that this program is allowing others to access and you should really only access things through those member functions. But I will strongly urge you to try out extending this program in at least one way. So please do that. So for example I said that if I click on a node its color should change to indicate to me that I clicked on that. So that is a relatively easy extension and I would definitely suggest that you try it out and I think it will be fun. I think you will see that it makes the program easier to use. So that is the end of this lecture. Thank you.