15,902,635 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Michael Hurt (Top 18 by date)
Michael Hurt
9-Jun-16 9:40am
View
Yeah I know what you mean but that won't work with the Plugin type or some others. I think I will just compare the length of each whilst I wait for a solution. Will get me out of trouble but not good programing.
Michael Hurt
9-Jun-16 8:20am
View
I have updated my question, if you read it again, it might give more insight.
Michael Hurt
9-Jun-16 8:12am
View
Exactly, so I need a work around.
One possibility I have thought of is to check the super types or interfaces of the super types or interfaces which should be the root interface. However this is a very long and convoluted method and I can't guarantee that it will work with all types.
Michael Hurt
9-Jun-16 7:43am
View
I have and I need help. This is why....
public myExample(List<string> myList) {}
The constructor now has parameter type "java.util.List"
Now lets create the list.
private List<string> myList = new ArrayList<>();
Ok, so now the list is of type "java.util.ArrayList"
So now lets compare the parameter in the constructor with the argument we just made to make sure we are passing the correct argument to the constructor.
if ("java.util.List" == "java.util.ArrayList") { doSomething() }
Whoops!
And so this is what I need help with.
if (cArgType.equalsIgnoreCase(ctorType.getTypeName())) {
ctorTypeMatches++;
break;
}
Michael Hurt
9-Jun-16 7:29am
View
I added one of the constructors so you can see where cArgs comes from.
Michael Hurt
9-Jun-16 7:21am
View
this is directly out of the log, however please also note that the comments after the NPE are what I wrote during my troubleshooting.
[21:17:01] [Server thread/ERROR]: Error occurred while enabling TestPlugin v0.0.1-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Incorrect argument type or length in ClassBuilder constructor
at au.com.mshcraft.testplugin.ClassBuilder.builtObject(ClassBuilder.java:199) ~[?:?]
at au.com.mshcraft.testplugin.ClassBuilder.getClassObject(ClassBuilder.java:52) ~[?:?]
at au.com.mshcraft.testplugin.CommandInterpreter.<init>(CommandInterpreter.java:30) ~[?:?]
at au.com.mshcraft.testplugin.TestPlugin.onEnable(TestPlugin.java:76) ~[?:?]
This error comes from:
try {
// the decider!
if (clsCtor == null) { throw new NullPointerException("Incorrect argument type or length in ClassBuilder constructor");}
// if (cArgs == null) { throw new NullPointerException("The constructor arguments object was null");}
handler = clsCtor != null ? clsCtor.newInstance(this.cArgs) : cls.newInstance();
Michael Hurt
4-Jun-16 20:25pm
View
Ok, its clear that I am not explaining the question well enough so I will try to be more clear.
In java, I remember that
ref: stackoverflow
String s1 = "FirstString";
String s2 = "FirstString";
if(s1 == s2) {
//This condition matched true because java don't make separate object for these two string. Both strings point to same reference.
}
So as I understand it, they now both point to the same memory location. Now if I pass one of them to a class or method, will the new object contained within that class or method now also point to the same memory location?
Michael Hurt
4-Jun-16 12:05pm
View
So talking about shared data and threads in java if I (Pseudocode)
public foo() {
var = 2
whatever(var)
}
Have I just passed a pointer for that memory location to whatever or have I just passed the data and created a new memory location assigned to whatever containing duplicate data? In thread terms, does the thread keep the same memory reference for var when it begins processing whatever?
Now if I
public whatever(int var) {
var = 1
file.save(var)
}
Do the threads processing foo now contain old data?
So now if I
public foo() {
var = idk
if (idk = 3) whatever(var)
bar(var)
}
Is bar now receiving outdated information? Are the foo threads that never enter whatever now using outdated data?
Michael Hurt
4-Jun-16 6:19am
View
Ok, I get it now. Worked perfectly.
Thanks.... :)
Michael Hurt
4-Jun-16 5:41am
View
What about the other way for setting data? I get an error with
boolean setData(List<e> data);
@Override
public boolean setData(List<string> data) {}
Michael Hurt
4-Jun-16 5:28am
View
Thanks. Looks interesting, I will try this and accept if works.
Michael Hurt
9-May-16 10:47am
View
I think I may have just found the answer.
http://www.java2s.com/Tutorial/Java/0100__Class-Definition/Polymorphism.htm
Would that be the best approach?
Michael Hurt
9-May-16 10:06am
View
This will be used to randomly create or edit/delete objects. The objects will be stored in a list which will have a limit of 10 objects. The effect will be that the objects will have a random life cycle.
Michael Hurt
9-May-16 9:28am
View
Yeah, I had trouble trying to get it clear in my own head. I'll try re-writing it.
Michael Hurt
8-May-16 20:38pm
View
I can see that you have made some really good points there. Its sometimes difficult to expand on an idea, without implying an opinion one way or another. Whilst writing the article, I have intentionally tried to avoid forming an opinion and be objective rather than subjective. It is apparent to me now that in doing so, I have been overly cautious and avoided issues which the article should have addressed.
It will take some time to reflect on some of your ideas and either come up with some new material, or expand on the existing. The approach I wish to stick to is in keeping the article short, simple and to the point.
Michael Hurt
8-May-16 10:28am
View
You are correct, I did try to keep it brief and give a general overview so as not to overload new programmers with too much information. My intention was to provide a brief introduction to some of the most important concepts, not to give an in depth lecture on each of the individual concepts. My alternate objective was to help them avoid some of the common road blocks along the way.
If you do believe that I have overlooked a concept that is extremely important, or that a section warrants reference materials or refinement. I would be all to happy to discuss any changed you might suggest.
Michael Hurt
8-May-16 10:26am
View
Deleted
You are correct, I did try to keep it brief and give a general overview so as not to overload new programmers with too much information. My intention was to provide a brief introduction to some of the most important concepts, not to give an in depth lecture on each of the individual concepts. My alternate objective was to help them avoid some of the common road blocks along the way.
If you do believe that I have overlooked a concept that is extremely important, or that a section warrants reference materials or refinement. I would be all to happy to discuss any changed you might suggest.
Michael Hurt
8-May-16 9:02am
View
Hi and thanks for replying. It was actually a difficult question to structure for a site such as StackOverflow as it is very ambiguous. How do you ask for something your not even sure exists? The short version is that the community there has become very intolerant and rather than helping me to improve my question, they just spammed it with a stack of down votes. This had an extremely negative impact on my reputation leaving me banned from asking further questions. In addition to the down votes, there were also a lot of negative comments which left me reluctant to post there in future.
Of course you are correct, no-one can design a template to suit a program I haven't even written yet. What I was looking for is a basic outline of a simple program which employs a range of different patterns. My hope was that it could provide some insight into which patterns are best suited to which types of situations. I just don't want to find myself beginning a section of program using the wrong type of pattern and having to re-write it.
I quickly came to realize that what I am searching for doesn't exist and so I wrote an article to help others who may have similar issues.
http://www.codeproject.com/Articles/1098482/Structured-Programing
At the moment im personally stuck on how to turn a switch case statement into a dictionary using custom IOC. Each case in the list invokes a method so I tried to load up a hashmap of the case with the method, however as soon as the compiler see's the assignment 'action.put("command", myCommand(args, user);', it immediately executes the method. And so you can see why im looking for such examples of how and where such patterns are appropriate and how others have implemented them.
Show More