|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Oh man, darkness, enterprise Java coding is a dark place...
+ Show Spoiler +com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState + Show Spoiler +Internal frame internal frame, title pane internal frame.
title pane maximize button, window not focused state
I can't speak much on the adapter pattern in particular because I've never seen it used in practice. It seems like it's used in cases where you would be unable to change earlier code, but have to fit it into your new design. So, yes, the overridden methods that do nothing are an example of poor design.
This pattern actually looks almost like it's a java implementation for function objects ("functors"), where you are able to change the usage of a function at run-time by creating classes that wrap a function. In this case, both the VLC and MP4 classes are wrapping around the "play" function, and the adapter class is mediating between which one it chooses based on the incoming parameters.
Sun's example here is pretty gnarly since it's trying to show an example where you would need to use functors, and then names the pattern off of the front-end of the language feature, rather than what's going on with the interfaces. In practice, you wouldn't have two playMP4 and playVLC functions, you would instead have two mediaplayer Objects, one named MP4Player and one named VLCPlayer, both would implement a playMedia function. At run time, the main program would detect the file type, and instantiate an object based on that, and then call the playMedia function.
Where it gets confusing is because the playMedia function might need different parameters depending on the file-type. Traditionally, this is done by passing the parameters into the VLCPlayer or MP4Player constructors instead of creating methods that do nothing, and crafting an "adapter" class to decide which one is being called. In the example this is done by creating an interface with both functions instead of using constructors.
|
On January 01 2014 01:29 enigmaticcam wrote: I've been racking my brain over this problem for a few days now, and have been unable to come up with an optimal solution. So I'm hoping you guys can help me out.
Suppose I have a random assortment of items I want to produce in x number of production facilities. I want to write a program to find the distribution that best minimizes the total time it takes to produce the items. Here are the constraints:
- A facility can only produce one item at a time. My goal is to backlog all facilities with all the items in a way that takes the least amount of time as possible to produce the items. For example, if I have three facilities and six items to produce, given that everything else is equal, the optimal solution is to split it evenly with two items per facility. - Certain items take longer than others to be produced. So if I have one item that takes fifteen minutes, five items that take three minutes, and two facilities, the best solution is to put the fifteen minute item in one facility and all the other items in the other facility. - A facility must have slots available in order to produce or backlog an item, and certain items take more slots than others. Also, some facilities have more slots than others. - Some facilities can only produce certain items.
I've tried using a dynamic programming solution, but every approach I've made fails because of the circular dependency between large subsets and the smaller subsets they encompass. For example, if I have two items and two facilities, trying to solve a smaller subset (like one item and two facilities) is pointless without knowing where the other item will be.
I could easily brute force the solution, but if I have a few hundred items and several facilities, the number of combinations can grow exponentially too large. My goal is to write an efficient program to solve this as fast as possible.
Any help would be appreciated! I'm doing this in C#.net, but pseudo code I can understand.
Your problem sounds like an instance of the job shop scheduling problem. It's an optimization problem, and theres a whole discipline called operations research related to solving these types of problems. I had a survey course about this so I can mention some background, but unfortunately I was never much good at this stuff xD
There is a lot of published research on the lines of "job-shop scheduling", "linear programming", etc, and some of the method used to solve linear programming problems are the simplex algorithm or interior point methods.
Incidentally, Excel actually has a combinatorial solver add-in that you can use if you wanted to solve a particular problem instance (this won't help you at all in writing your code, of course). It's called the excel solver and is an addin you can download if you have Excel. There's also a whole set of industrial strength solvers such as CPLEX.
Sorry I couldn't be of any practical help, just sharing in case anyone else finds this stuff interesting.
|
On January 01 2014 10:54 teamamerica wrote:Show nested quote +On January 01 2014 01:29 enigmaticcam wrote: I've been racking my brain over this problem for a few days now, and have been unable to come up with an optimal solution. So I'm hoping you guys can help me out.
Suppose I have a random assortment of items I want to produce in x number of production facilities. I want to write a program to find the distribution that best minimizes the total time it takes to produce the items. Here are the constraints:
- A facility can only produce one item at a time. My goal is to backlog all facilities with all the items in a way that takes the least amount of time as possible to produce the items. For example, if I have three facilities and six items to produce, given that everything else is equal, the optimal solution is to split it evenly with two items per facility. - Certain items take longer than others to be produced. So if I have one item that takes fifteen minutes, five items that take three minutes, and two facilities, the best solution is to put the fifteen minute item in one facility and all the other items in the other facility. - A facility must have slots available in order to produce or backlog an item, and certain items take more slots than others. Also, some facilities have more slots than others. - Some facilities can only produce certain items.
I've tried using a dynamic programming solution, but every approach I've made fails because of the circular dependency between large subsets and the smaller subsets they encompass. For example, if I have two items and two facilities, trying to solve a smaller subset (like one item and two facilities) is pointless without knowing where the other item will be.
I could easily brute force the solution, but if I have a few hundred items and several facilities, the number of combinations can grow exponentially too large. My goal is to write an efficient program to solve this as fast as possible.
Any help would be appreciated! I'm doing this in C#.net, but pseudo code I can understand. Your problem sounds like an instance of the job shop scheduling problem. It's an optimization problem, and theres a whole discipline called operations research related to solving these types of problems. I had a survey course about this so I can mention some background, but unfortunately I was never much good at this stuff xD There is a lot of published research on the lines of "job-shop scheduling", "linear programming", etc, and some of the method used to solve linear programming problems are the simplex algorithm or interior point methods. Incidentally, Excel actually has a combinatorial solver add-in that you can use if you wanted to solve a particular problem instance (this won't help you at all in writing your code, of course). It's called the excel solver and is an addin you can download if you have Excel. There's also a whole set of industrial strength solvers such as CPLEX. Sorry I couldn't be of any practical help, just sharing in case anyone else finds this stuff interesting.
reminds me of 0-1 knapsack problem (greedy or dyn sol). worth would be time required to produce item. weight would be required slots to produce item. maybe try to solve 0-1 knapsack for each facility greedily (sorted by available capacity at each timestep to make sure you are making greedy choice) along discrete time axis (increment time if you are out of capacity to produce any more in all facilities) until all items are scheduled.
|
Alright so I have the ol' newbie question of "what language should I learn?" that I hope you guys can help me out with. Here are the main goals I want to accomplish:
I want to create a "real program"; a straight exe on my desktop that isn't going to require me to run a script through a compiler every time I want to use it. It needs to be able to store and recall information. I want it to have drop down menus and buttons. Ideally, I'd like it to create print out summaries based on variables I give it. As a more "real" example, what I basically want to do is to track people, groups, employees, or whatever you want to call them and and provide updates on them that get sent out to other people.
+ Show Spoiler +Lets say Adam, Becky, and Chris work on planning events a couple times a week. Chris calls me on Jan 8th at some time to let me know that he, Adam, and Becky are going to be working on the planning committee today and that they got into the office at 8am. I want to be able to input into the program something like: planning group, january 8th, Adam, Becky, Chris, 8am, Chris' phone number. The program should be able to store in a fashion that I can access it later (the title of the job for the day, the date, group members, clock-in time, contact information). For example later I want to hit "contact" button, type in "Chris" or "Planning group" and it should give me Chris' phone number. If Chris calls me later and says they're eating lunch with a client, I want to hit a button that says "meet up"(given that this group routinely has these lunches), followed by typing in "12:00PM, client lunch".
Finally, when I generate my reports to be sent out in an email, I want it to display all the useful information neatly "Planning group jan 8-Adam, Becky, Chris, 8am" "8am clock in" "12pm client lunch" and so on and so forth.
Some other key points: Since I work with Chris frequently, his number should be able to be stored or altered within the program. I shouldn't have to type in his number every time morning when he calls me to let me know he got into the office. The event planning committee has a budget, guidelines, deadlines, rules(that sometimes change, sometimes don't) that they have to follow and this is currently stored on a word doc that I have to manually change the date on and send to them every morning. I deal with at least 10+ groups, so I'd like to have something like a template saved somewhere, and if there's no change, and I can press a button or type-in inputs like: generate daily report--planning committee--jan 8--no change, and it would generate the same report as the day before but simply with a different date.
Originally I was looking into C++ and the QT GUI to accomplish this, but I want to run this by someone who actually knows if what I'm learning can do what I want. I don't need any tips or code lines or that sort of thing to actually write the program, I just want to know if it's feasible. Thanks! :D
|
C# would be your best bet on Windows (I'm assuming Windows because you said .exe). C++ Qt is painful imo, Visual C# is a lot simpler to get the hang of.
Do you want your changes to be reflected across all your clients computers or something like that? Or is this program just for yourself? I haven't done much networking stuff in Visual C# so I'm not 100% on how you would implement that portion, but everything else seems easily doable with C#.
|
C# is indeed a decent and fairly easy starting point. However I myself found (coming from C++) to dislike it to the point where I prefer C++ over C#, however as Blisse said, for starters C# is easier especially if you need a quick and no-nonsense GUI. Qt with C++ is a fairly bit more complex, but also a lot more functional once you do get the hang of it and are a more experienced coder.
From my point of view:
C# == Duplo (simple to start with but not always as flexible) C++ == Lego (more complex, but more flexible)
|
On January 03 2014 15:49 Blisse wrote: I haven't done much networking stuff in Visual C# so I'm not 100% on how you would implement that portion, but everything else seems easily doable with C#. No worries, C# has really strong networking as well.
Personally, I would say C# is always the right choice if you want to make a real program and you're using Windows. If you're using linux, it's up in the air between Java and Mono (I hate Java, but then again, Mono is not always reliable). It just makes you massively productive in a way C++ does not let you be. C++ is awesome if you desperately need to work with memory directly or you can't deal with having garbage collection overhead (or you need to be unmanaged for some reason). For any other situation, I can't think of a reason why one would use C++ rather than C#.
|
On January 03 2014 15:43 phiinix wrote:Alright so I have the ol' newbie question of "what language should I learn?" that I hope you guys can help me out with. Here are the main goals I want to accomplish: I want to create a "real program"; a straight exe on my desktop that isn't going to require me to run a script through a compiler every time I want to use it. It needs to be able to store and recall information. I want it to have drop down menus and buttons. Ideally, I'd like it to create print out summaries based on variables I give it. As a more "real" example, what I basically want to do is to track people, groups, employees, or whatever you want to call them and and provide updates on them that get sent out to other people. + Show Spoiler +Lets say Adam, Becky, and Chris work on planning events a couple times a week. Chris calls me on Jan 8th at some time to let me know that he, Adam, and Becky are going to be working on the planning committee today and that they got into the office at 8am. I want to be able to input into the program something like: planning group, january 8th, Adam, Becky, Chris, 8am, Chris' phone number. The program should be able to store in a fashion that I can access it later (the title of the job for the day, the date, group members, clock-in time, contact information). For example later I want to hit "contact" button, type in "Chris" or "Planning group" and it should give me Chris' phone number. If Chris calls me later and says they're eating lunch with a client, I want to hit a button that says "meet up"(given that this group routinely has these lunches), followed by typing in "12:00PM, client lunch".
Finally, when I generate my reports to be sent out in an email, I want it to display all the useful information neatly "Planning group jan 8-Adam, Becky, Chris, 8am" "8am clock in" "12pm client lunch" and so on and so forth.
Some other key points: Since I work with Chris frequently, his number should be able to be stored or altered within the program. I shouldn't have to type in his number every time morning when he calls me to let me know he got into the office. The event planning committee has a budget, guidelines, deadlines, rules(that sometimes change, sometimes don't) that they have to follow and this is currently stored on a word doc that I have to manually change the date on and send to them every morning. I deal with at least 10+ groups, so I'd like to have something like a template saved somewhere, and if there's no change, and I can press a button or type-in inputs like: generate daily report--planning committee--jan 8--no change, and it would generate the same report as the day before but simply with a different date.
Originally I was looking into C++ and the QT GUI to accomplish this, but I want to run this by someone who actually knows if what I'm learning can do what I want. I don't need any tips or code lines or that sort of thing to actually write the program, I just want to know if it's feasible. Thanks! :D
Honestly, what you describe does not look horrendously complex. Thus, pretty much any language is able to give you what you need to deploy such a program (C++, C#, Java, Python...)
Now, the real problem is : how easy (and maintainable) is it to do it in various languages? I am no C# expert, so I can't talk about this language, but as someone who uses extensively C++, I can tell you that Qt makes everything you say trivial. You can design everything in the Designer (QPushButton, QLineEdit, etc..), read and write in files (QFile, but QJsonDocument seems better for your purpose)
I am pretty sure C# and Java too have the tools necessary to do what you want. In fact, I know they do.
To finish, I am sorry, but don't listen to simplifications such as "C++ is here if you want raw power and access memory". Well, yes, but if you are not a professional programmer who is worried about extremely specific things, these considerations do not really matter for you. I use C++ because it suits my needs, and because it has among the sexiest libraries in the world (Qt, OpenCV and Eigen notably for me)
|
On January 03 2014 19:04 fezvez wrote: To finish, I am sorry, but don't listen to simplifications such as "C++ is here if you want raw power and access memory". Well, yes, but if you are not a professional programmer who is worried about extremely specific things, these considerations do not really matter for you. I use C++ because it suits my needs, and because it has among the sexiest libraries in the world (Qt, OpenCV and Eigen notably for me)
Indeed. A consideration that does matter for a non-professional programmer might be the fact that it takes about 10 times longer to write the same program in C++ as it would in C#. Even libraries usually require far more manual code-writing than .NET. C++ has some cool libraries, but one might wonder where a non-professional user sees the need for OpenCV (and if you need it, there's always the EmguCV wrapper for .NET). I would say the same with Eigen, but then again, I write mostly web applications and rarely find any use for complex math in my programs. QT is nice but not even close to as easy to work with as WinForms.
In my opinion, a person should always pick the language fit for the task which forces you to do the least amount of work. From this perspective, C++ is rarely a good choice. C# stays close performance wize, having mostly the same capabilities and is far faster to write code in. If you don't need a GUI, I would say Python is usually an even better choice.
Above all though, obviously, one should use the language one is most comfortable in, so I'm not saying you shouldn't be using C++, I'm saying a person who has no real experience with programming should probably pick a different language.
|
Uhh yeah I'd agree with the last couple guys on most points.
One thing that I haven't seen said is that often the best language for the job is the language you're best at, especially if you're pretty new and only know one language.
However if you haven't yet learned any language you'll basically never want to create a project in C or C++. You should only use C or C++ to learn them, not to create things. IME people that learn C and C++ do it for a living, not to finish the occasional project.
|
On January 03 2014 19:52 CecilSunkure wrote: Uhh yeah I'd agree with the last couple guys on most points.
One thing that I haven't seen said is that often the best language for the job is the language you're best at, especially if you're pretty new and only know one language.
However if you haven't yet learned any language you'll basically never want to create a project in C or C++. You should only use C or C++ to learn them, not to create things. IME people that learn C and C++ do it for a living, not to finish the occasional project.
Emphasis on this - Tommy Refenes (the Super Meat Boy programmer) wrote an article that goes a bit more in depth about this but it boils down to basically, the language that is best is the language that allows you to do the most, and that's usually the language you know your way around. I actually find I have an easier time developing in C++ than I do C# - but I know that's just because I'm a way more experienced C++ developer than I am in C#. Still, I do most of my personal programming in C++ because I just like it, goddammit, and that's the reason you should choose your language too.
If you're just starting out, do a bit of reading! Figure out a few languages you think might be good and then do your research (if you have problems with this part literally everyone in this thread will list like ten for you lol). Once you find something you think you'll like (NOT SOMETHING YOU THINK IS THE 'BEST' FOR YOUR PROGRAM) then go get started on that. If you realize later that it wasn't a good language to choose - well, you probably already finished your project, so next time you have that opportunity. Point being, you don't know enough to have good reasons, so go with something you think sounds cool.
|
c++ is my language of choice, therefore i will recommend it to you. c++ is so cool... you can even write programs within the programs for the program that makes the programs. that's so meta and cool.
|
I like C++ a lot, it's very interesting and extremely powerful, but let's be real, it's a bad choice unless you're really good with it.
|
which is an excellent reason for making a lot of really bad choices! ;>
|
|
|
On January 04 2014 02:19 spinesheath wrote: I like C++ a lot, it's very interesting and extremely powerful, but let's be real, it's a bad choice unless you're really good with it.
Even when you are good with C++, unless there are definitive reasons to use it, I'd always pick C# over it. C++ has a few advantages, most notably probably the slightly better performance and much lower memory footprint. However, C# allows you to develop the same application in less than half the code and it has the really great .NET framework, so if your business depends on getting things out fast - which almost all software companies do - then C# is usually the better pick.
C++ is still a great language, especially with improvements it got in C++11
|
On January 04 2014 04:09 Morfildur wrote:Show nested quote +On January 04 2014 02:19 spinesheath wrote: I like C++ a lot, it's very interesting and extremely powerful, but let's be real, it's a bad choice unless you're really good with it. Even when you are good with C++, unless there are definitive reasons to use it, I'd always pick C# over it. C++ has a few advantages, most notably probably the slightly better performance and much lower memory footprint. However, C# allows you to develop the same application in less than half the code and it has the really great .NET framework, so if your business depends on getting things out fast - which almost all software companies do - then C# is usually the better pick. C++ is still a great language, especially with improvements it got in C++11 I'd agree with that, except for C++ being a great language, but that's a matter of personal preference. (I will agree that C++11 makes the language quite a lot nicer to use) C# has Visual Studio, which is a fantastic IDE with a very nice GUI editor (for both Windows Forms and WPF). C# is also just a lot of fun to use. It feels like Java with a lot more features and less of "you are not allowed to use that because you might cut yourself" (operator overloading, unsafe code sections and things like that). It also has quite decent functional programming support with LINQ, tuples, function pointers (Func/Action) and type inference.
|
On January 04 2014 04:09 Morfildur wrote:Show nested quote +On January 04 2014 02:19 spinesheath wrote: I like C++ a lot, it's very interesting and extremely powerful, but let's be real, it's a bad choice unless you're really good with it. Even when you are good with C++, unless there are definitive reasons to use it, I'd always pick C# over it. C++ has a few advantages, most notably probably the slightly better performance and much lower memory footprint. However, C# allows you to develop the same application in less than half the code and it has the really great .NET framework, so if your business depends on getting things out fast - which almost all software companies do - then C# is usually the better pick. C++ is still a great language, especially with improvements it got in C++11
But the same could be said of many high-level languages over C# (e.g Ruby, Coffeescript), what makes C# the better choice?
|
Thanks for all the input! I was pretty sure that C++ could handle it and was also looking to see what alternatives I had to it, and it looks like c# is the choice. I know all in all the program isn't too complex which is why I picked it as some what of a starting point for me to get into programming. I have a decent handle on writing VBA, but to me it's a lot different than writing in a language like C and all it's derivatives.
|
On January 04 2014 04:35 phiinix wrote: Thanks for all the input! I was pretty sure that C++ could handle it and was also looking to see what alternatives I had to it, and it looks like c# is the choice. I know all in all the program isn't too complex which is why I picked it as some what of a starting point for me to get into programming. I have a decent handle on writing VBA, but to me it's a lot different than writing in a language like C and all it's derivatives. I was about to come in here and say - don't be fooled by the fact that there are so many people talking about C# in this thread, there are very possibly better options out there. As someone with experience in C#, C++, Python and Lua, when my girlfriend decided she wanted to try her hand at some programming, I introduced her to Python first. I mean, that's just my two cents, but there has been so much talk in this thread lately about C# that I wanted to make sure other languages got some love too, if only to make sure you actually looked at them ^^
e: to expand a little more - what you propose is literally possible in every programming language I can think of that's used majorly today, so don't at all limit yourself to what you think 'your program needs'. You could design that in any one of fifty languages - look at a few of them before you really decide where you want to start learning ^^
|
|
|
|
|
|