4 Replies - 4972 Views - Last Post: 09 January 2012 - 04:39 PM

#1 immeraufdemhund  Icon User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

General questions about extending Objects

Posted 08 January 2012 - 08:06 AM

Sorry if this has been asked, I was thinking about these questions while I was getting ready to leave, and so I haven't had a chance to really look up anything (like I will do when I get home).

I've been in Java programming for a long time, and like how it looks and feels, and I've found very good resources (mainly talking about Oracle's API) on every aspect of Java. That being said now that I've decided to try and learn C# I find my self looking for the very same things out of it, but am finding it hard to find and navigate through the MSDN. (Which is why I gave up on C++) I have found though if i type in a class and append C# google takes me directly to the MSDN article which is nice. So this is my first question. If i have a question on how to use or implement a object in my code were is a good place to have all the API at my fingertips sorta like the oracle's API? (does such a thing exist?)

Second question is because netbeans is so horrible at generating code using the GUI builder I've become accustomed to making all my windows by hand. I like the versatility of most of the Layouts. Does c# have layouts? Should I use the visual c# gui builder?

Also I have come to the point now were I extend almost all my visual aspects of my program. I'll extend JFrame from my main class. I'll add custome JPanels all over the place. I'll extend JButtons frequently. Does c# do that? Should I do that in c#?

I know it's not fair to compare one language to another because they were build with different audiences in mind, and built for specific platforms (if universal is specific :) ) But I've just been working with it for so long it is hard not to compare the too and revert to my old habits from java while learning and using C#.

Last question. I've been learning how to use the WMI for c# and I have to say that is a SUPER cool feature of c#. I'm actually trying to make a program for work that gathers a ton of information about the computer we are working on so I know if it was configured correctly, and WMI almost has all the features I'm looking for... But is it really the tool I should be using? Is it slow, does it take up a lot resources?

Is This A Good Question/Topic? 0
  • +

Replies To: General questions about extending Objects

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5595
  • View blog
  • Posts: 11,970
  • Joined: 02-June 10

Re: General questions about extending Objects

Posted 08 January 2012 - 08:51 AM

View Postimmeraufdemhund, on 08 January 2012 - 09:06 AM, said:

I have found though if i type in a class and append C# google takes me directly to the MSDN article which is nice.

The very same advice we dispense regularly and I even wrote a 'how to' article on.

tlhin`toq said:

Finding answers to specific problems:
Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.
How to do a good search that will get you targeted answers.


View Postimmeraufdemhund, on 08 January 2012 - 09:06 AM, said:

If i have a question on how to use or implement a object in my code were is a good place to have all the API at my fingertips

That would be the MSDN. Though I think it is often a dry read. But that is where it *all* will be. Next after 'all' is 'most common need' and that's just a matter of digging through Google results for how to's and tutorials and blog listtings depending on the complexity of what you are searching out.

View Postimmeraufdemhund, on 08 January 2012 - 09:06 AM, said:

Should I use the visual c# gui builder?

That would be Visual Studio. There are free versions.
Free editions of Visual Studio 2010

View Postimmeraufdemhund, on 08 January 2012 - 09:06 AM, said:

Does c# do that? Should I do that in c#?

Yes it does. Yes you can. 'Should' you depends on your needs.

I know it's not fair to compare one language to another because they were build with different audiences in mind, and built for specific platforms (if universal is specific :) ) But I've just been working with it for so long it is hard not to compare the too and revert to my old habits from java while learning and using C#.

View Postimmeraufdemhund, on 08 January 2012 - 09:06 AM, said:

Last question. I've been learning how to use the WMI for c# and I have to say that is a SUPER cool feature of c#. I'm actually trying to make a program for work that gathers a ton of information about the computer we are working on so I know if it was configured correctly, and WMI almost has all the features I'm looking for... But is it really the tool I should be using? Is it slow, does it take up a lot resources?

As a rule, we try to write software without knowing the nuts and bolts of the hardware. Certainly without depending on it. But if you are writing a hard drive defragging tool, then you have a need to get down to that level. If you are writing a vacation time scheduling app, then you don't have that need.

There's a lot of stuff in this resources post I give to rookies. Some might be helpful to you, some not.


Resources, references and suggestions for new programmers. - Updated Dec 2011
Spoiler

Was This Post Helpful? 1
  • +
  • -

#3 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4537
  • View blog
  • Posts: 7,916
  • Joined: 08-June 10

Re: General questions about extending Objects

Posted 09 January 2012 - 09:37 AM

Quote

Second question is because netbeans is so horrible at generating code using the GUI builder I've become accustomed to making all my windows by hand. I like the versatility of most of the Layouts. Does c# have layouts? Should I use the visual c# gui builder?

Also I have come to the point now were I extend almost all my visual aspects of my program. I'll extend JFrame from my main class. I'll add custome JPanels all over the place. I'll extend JButtons frequently. Does c# do that? Should I do that in c#?


Well, the C# GUI builder is far more worthy of your trust than the netbeans one. Feel free to use it, because coding a UI by hand is a pain in the ass.

As for extending, you can, but it's not really the common way, like it is in Java. If you need a custom behavior or look for a component, you can make a UserControl.

As for "Layouts" I wouldn't know, because I haven't done any Swing. On the other hand, if you're really looking for flexibility, I suggest WPF. It's by far the most versatile GUI building mechanism I've ever seen, and it keeps the code away from the UI building. It's XML-based, so you get logical separation.

Also, I'm moving this topic to the advanced discussion, since it's not really a help topic, but more of a discussion.
Was This Post Helpful? 1
  • +
  • -

#4 immeraufdemhund  Icon User is offline

  • D.I.C Regular

Reputation: 79
  • View blog
  • Posts: 495
  • Joined: 29-March 10

Re: General questions about extending Objects

Posted 09 January 2012 - 04:16 PM

Quote

As for extending, you can, but it's not really the common way, like it is in Java. If you need a custom behavior or look for a component, you can make a UserControl.


interesting. I was noticing that visual studios extended Form and a few other things. I will have to look into user control because for the program I have been working on I started extending different controls such as Labels and TextBox's so that they would all be uniform in size, border, and design. I made a few functions to mimic the gridLayout in java. I don't like how I did it though, but I deffinatly don't like using hard coded numbers even more. I like that I can change the size of all my components and it automatically adjusts the location on the screen of each of my components like I am used to.

as a side note I half way considered making my own "JPanel" :) and having a custom Layout for each. But then I was like nah... So i ended up opening up the GUI builder and watching how it did padding and locations and lining up. So far as I can figure it just always hard codes the numbers in, and like I said I just don't like that. It makes me uneasy. What if a user resizes the form? or in my case what if I switch resolutions? I find that to be the difficult part in using hard coded numbers. In fact I ran into that at work. Our head programmer made our tracking software for each computer that we fix/build. He uses a Visual system, and has it put in all the numbers. But the problem is that the people in sales have a 20" widescreen monitor at a normal widescreen resolution. The tech room has a 15" running 1024x?768?. So when we open the program the edges of the program are lost. many of the text boxes aren't sized correctly, and many other nitpicking things. Oh well. I guess I shouldn't complain too much I just am of the opinion that if a professional programmer makes something then asside from a few bugs here and there the program should be close to perfect. None of this weird sizing things. Can you imagine how many people would buy MS windows if something as silly as sizing was not paid attention too? I would imagine the numbers would drop considerably. Enough of me ranting. Thank you very much for helping me get a better grasp of becoming a C# programmer.
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4537
  • View blog
  • Posts: 7,916
  • Joined: 08-June 10

Re: General questions about extending Objects

Posted 09 January 2012 - 04:39 PM

Quote

It makes me uneasy. What if a user resizes the form? or in my case what if I switch resolutions? I find that to be the difficult part in using hard coded numbers.


For this, the "Anchor" property defines how components attach to edges. I don't work with WinForms that much, so I don't remember all the mechanics off the top of my head, but it's both possible and fairly easy to make a resize-friendly form. There's also an AutoSize and AutoSizeMode property as well. Also, some controls have a Dock property. They just default to absolute positions and sizes because that's the easiest behavior to predict.

Also, you should look in the "Containers" tab of the GUI Builder Toolbox. There's some Panels that allow you to mimic some of the Layouts you're looking for. There's a FlowLayoutPanel, a SplitContainer, and a TableLayoutPanel. These should help somewhat.

Again, though, if you're looking for serious flexibility, I suggest you look into WPF. It's amazing what you can create with that.

Quote

I was noticing that visual studios extended Form and a few other things. I will have to look into user control because for the program I have been working on I started extending different controls such as Labels and TextBox's so that they would all be uniform in size, border, and design.


Well, I didn't even think about it like that. For forms, you actually are making your own class and extending Form, so that's a lot like extending JPanel. You could extend Button and TextBox if you really wanted to set some of those things, but if you're using the GUI builder, it doesn't help that much. As for in-code UI elements, I'd prefer some sort of method that would create a button, and set all the properties to my defaults, then returns the button (sort of like a constructor would, but without the overhead of a new class).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1