Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Friday, September 11, 2015

Circling the globe (the thoughts in my head)

I went on vacation this last week.  I didn’t spend any time working.  It was wonderful.  Now, it’s Saturday and I’m back to getting ready for work.  The mental processes are starting to grind away, and get back to what I was working on.  At the moment, I’m updating Visual Studio so I can work on the program I was writing in C#.  I know I’ve heard a lot of disparaging things about C#, but I’m not terribly concerned.  There are too many purists in the world. 

C# is a tool.  Nothing more.  If it’s not the tool you need for the job, then don’t use C#.  C++ is a tool.  Java is a tool.  Visual Basic is a tool.  They are all tools.  Nothing more, nothing less. 
Each tool out there has a specific use, and some tools are better for certain applications.  I can’t say C# is any better a tool than Java in this case, but it’s a tool I can manipulate easier.  I also spend a lot less time fighting the interface and more time working on what I’m interested in working on.  As such, the thing already reads XML files, runs threads, and generally works like I want it to.  It’s not complete by any means, but it’s on its way there. 

In the period since I started writing this (it’s been about a week) I read Seth Godin’s Small in the New Big.  It’s quite a remarkable book, and there’s a lot I’d like to say about it.  I’m really not sure what to say, though.  There truly has been a paradigm shift and in the world, and those trying to follow the old paradigm seem to be getting left behind.  It’s much easier to follow the new paradigm.

But what is the new paradigm?  I think the answer is release early, release often, and benchmark everything.  Quit trying to make something perfect, and make something you can release. 

So I think I’m going to go with that, and make something I can release.  I’ve already started working on it, but it’s neither groundbreaking nor amazing.  But it’s something. 

When you release often, you end up basically throwing a lot of stuff up, and hoping some of it sticks.  I’m not sure if that makes sense, but it does to me.  If I release something in the next month or so, then I’m doing better than I have in the last few years.  Too much thinking and trying to come up with the perfect idea.  Too little time releasing. 


I think I also realized the background for the past few months (maybe a year) has been chemistry related.  I like the picture, but this has nothing to do with chemistry.  I should probably change that.

Wednesday, August 26, 2015

C# this time, and Lua

Well, after a bit of digging, I'm back into C#.  I'm looking at that because of the need to examine the current status of a network.  And I had something like that built in VB.net, but i couldn't figure out threading.  So the program didn't play nice or update very well.

Well, I found a few webpages and figured that out.  This post on dailycoding.com was one of them.  That really helped get the ball rolling, so now I can run a ping function in the background and invoke updates to get things changed during program execution.  I'm guessing that I finally learned something out of that one because the code had been stripped down enough to where there wasn't a huge collection of extemporaneous junk that needed beat past.  Is it that hard to write code documentation that gives basic understanding without having to reinvent the wheel?

Which brings me to Lua.  I started using some products from Digital Loggers.  Basically the Rack Mount AC PDU.  It's a great product with a great concept, but changing from Basic on the Web Power Switch to Lua on the Rack Mount AC PDU causes havoc.  All the scripting type stuff that used to be easy with the Basic scripting language now has to be rewritten from scratch.

Did I mention you have to fight past bad Lua documentation?  I'm not necessarily saying Lua has bad documentation.  I'm saying Digital Loggers implementation of Lua is a pain.

For example...

function test_display()
    DISPLAY "\1Percent %%\v"
    DISPLAY "\2Backslash \\\v"
    DISPLAY "\1%a\v" --  current Bus A

This is an example of some code provided to change the display.  

Great.  Can someone tell me where the variable name is in that code block?   I know the -- blocks are comments.  DISPLAY is a command to show something on the display. Got that working.  Great.  

Secondly, on the script bit I know the line \1% indicates the first line, and anything afterwards is printed out.  But where is the variable?  

So if I want to put in a wait function, and then display on the screen "rebooting computer", I have to write individual reboot functions for every single device.

I could just write a wait(time in seconds, device name as string) function and call that whenever I needed.  But as is, it looks like I'm having to write inline functions.

Joy.  That defeats the entire purpose of object oriented coding and complex scripting languages.

Tuesday, January 6, 2015

Program 2: Java Stopwatch

With the NetworkStatus application in a mostly working state, it’s time to shift gears to a separate application.  I like to build small, similar applications that will eventually use the same basic ideas.  The first application was designed to get a button working and responding to being pressed.  Program two is about threading.

And what better way to move to in to threading than my old favorite of the threading world, the Stop Watch.  StopWatch will be of similar design to NetworkStatus.  The thing would have several buttons allowing you to adjust the time, and display in the middle of the screen.  There should be a start and stop button.  So I guess the first thing is to pull up paint and create a generic mockup of the program design. 

I decided to go with a 3x4 grid layout simply because it’s different than the gridbag layout I went with earlier.  I’m still not impressed with Java FlowLayouts, and GUI design in general seems like a real pain.  But I’ve got to learn to work with what I have to work with.  Some systems just seem to be better suited for certain things than others. 


The number in location 0,1 and 2,1 will be independent of each other.  They will be separated by a colon.  The colon ends up being just a text field with the text size increased to make it look pretty.  Really, the 0,1 and 2,1 are text fields as well.  They will just be handled with some special code to make them operate properly.  It’s not complex code, and I’ve written the same thing in other languages before. See my C# example below.


Though after examining my old C# stop watch, I might put a reset button in the middle.  That could work out nicely.  So, half an hour into this project I have a reasonable (though ugly) facsimile of a StopWatch.  It is not fuctional, and I need about 200-300 more lines of code to make it work without threading.  But at least there’s been some progress made.  Maybe tomorrow, it will be counting. 


Probably not.  It will take all of tomorrow to get the buttons working properly.