My own code vs library [closed] - java

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
This is kind of unusual question for developers but for some reason i want to post it here and hope to get adequate answer.
Here is a simple example:
I wrote a java function that calculates distance between two geo points. The function is not more than 50 lines of code. I decided to download a source code from ibm that does the same thing but when i opened it i saw that it looks very complicated and is almost thousand lines of code.
What kind of people write such source code? Are they just very good programmers? Should i use their source code or my own?
I have noticed this kind of thing lots of times and i from time to time i start to wonder if it is just me who do not know how exactly to program or maybe i am wrong?
Do you guys have the same kind of feeling when you browse throught some other peoples source code?

The code you found, does it do the exact same calculation? Perhaps it takes into account some edge cases you didn't think of, or uses an algorithm that has better numerical stability, lower asymptotic complexity, or is written to take advantage of branch prediction or CPU caches. Or it could be just over-engineered.
Remember the saying: "For every complex problem there is a solution that is simple, elegant, and wrong." If you are dealing with numerical software, even the most basic problems like adding a bunch of numbers can turn out to be surprisingly complex.

Related

Usage of java.util.ArrayList in ColdFusion [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am working on some old ColdFusion code. It probably dates from late '90s. It was programmed using
queryParams = createObject("java", "java.util.ArrayList");
...
arrayAppend( queryParams, {...});
...
It is looking like a normal array. I am wondering if someone just created a normal ColdFusion array the hard way.
To preface this... My comment was an educated guess. The only person who could give a truly objective answer for a question like this is the champion who originally wrote the code you're looking at.
But yes, it's entirely possible (probable?) that the way people handled Arrays in Coldfusion 20 years ago would seem alien to us in modernity. ArrayNew() simply did not exist.
Pro Tip to anyone who reads this in the future: Adobe's help documentation usually has a "history" section that shows when functions came to be, or when they stopped being supported.
https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-a-b/arraynew.html
ArrayNew
> History
Introduced in ColdFusion MX
EDIT
From the comments, I have been informed that Adobe's official page appears to be wrong. I see there are books that reference the ArrayNew function all the way back until at least ColdFusion 4 in 1999.
I suppose it's still possible that OP's code is old enough to pre-date that function since he didn't give us a version, but an interesting development nonetheless.

Run a math expression from string in java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to know if there is any efficient method to Run a math expression from string in java , Having some example input and results of that function.
Starting from simple linear functions : a*x+b .To more complex ones
Or is there any good source i can start reading.
I take your task as: take observed input-output and learn some representation which is able to do that transformation with new inputs.
(Some) Neural Networks can learn an approximation-function (Universal approximation theorem
) (and probably other approaches), but there is something important to remark:
Without assumptions about your function (e.g. smoothness), there can't be an algorithm achieving what you want to do! Without assumptions there are infinite many approximation-functions, which are all equally good on your examples, but behave arbitrarily different on new data!
(I'm also ignoring special-cases as: random-data or cryptographic random-generators where this mapping also can't be learned (the former in theory; the latter at least in practice)

user defined functions vs built in function in java five relevant differences over time and space complexities [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please explain me the differences over time and space complexities in java for user defined and predefined functions in java. examples like, linked list, list, stack class. please explain this with valid example.
thank you.
There is nothing special in predefined function over user defined. The only thing is predefined has been written by somebody else for you. It depends on algorithm.
Crap code/implementation runs in a crap way. Doesn't matter if its user created or system/API provided. example at a high level is EJBs vs Spring.
Good written code runs pretty and sleek. Again doesn't matter who the hell wrote it.

Should names be in good english? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
(This might be the wrong place to ask the question, please let me know).
Should I name my method isStaticallyImported or isStaticlyImported?
(They'd be pronounced pretty much the same way, I believe)
Of course they should be in good english. Even if the human brain will likely have no problems reading garbled up words, compilers do not enjoy the same luxury.
How many times have you miswritten a variable name, then later on used the correct spelling, only to find out that the program crashed at run/compile time?
This problem is only amplified when working on code that was not written by you, because we think of things as, well, things, and having to specially remember that the thing had to be spelled in a special way is just an unneeded break to your workflow.
Yes, your variables should be clear to the developer. You can name it whatever you want and it will work because the compiler doesn't care. When you name the variable in a human readable manner then developers after you will be able to read and understand your code much easier. You should name it "isStaticallyImported".
They should be in the most easily understandable language for those using and maintaining it in my opinion.
I'm also pretty sure the compiler doesn't care about the quality of spelling.

Java Questions [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm TAing for an introductory course in Java for freshmen. So, far we've learnt most of Java except the OOPS part. Like we can do methods, loops, control stuctures, arrays, strings, recursion etc..
Since this is their first programming course, they are not aware of fancy datastructures yet.
I have dont most of the regular programs like factorial, fibonacci, primes etc..
I'm looking for some interesting problems in the space without using complex datastructures. Any ideas would be super helpful.
thanks, Vinbot
Project Euler has some problems that you can solve without additional data structures, and all the problems have the nice property of being mathematically interesting. Not all the problems will work for your course, but I bet you can find enough that do, especially among the first few.

Categories