Ali Khalfan

Ranch Hand
+ Follow
since Nov 03, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ali Khalfan

I will try to start by just using JPA and store everything in a relational database than maybe use elasticsearch. I will see how that works

9 years ago
I'm developing a JSF application, where I have all the objects sorted out (using good old inheritance and association) .

Obviously, I plan to save this data somewhere. First thing came to mind is stored as objects into a relational database. But I fear that might cause a problem since I plan to use indexing later (such Apache Solr), so I fear just storing data as objects might might hinder indexing.

Would it be a good idea to store the data as a flat file? Or is there another technology I need to look for? I guess my question is, what options to I have ?


9 years ago
Hi All,
I'm trying to use JSF for mobile view (not an app, just something friendly on the browser)

I'm currently using mojarra 2.2.19 and the standard html and core library. I realize when using something like

the code looks good on desktop, but terrible on mobile

is there a better jsf implementation to use? or how should I approach this ?
9 years ago
JSF
hi Winston,

In your case, it's also quite dangerous, because you're changing something that is used to determine uniqueness, and that's usually very bad news



I agree changing something that determines uniqueness is dangerous, but I'm actually changing one of the attributes (e..g. in an object Student with attributes studentId and overallGpa, I'm sorting by overallGpa but the uniqueness is the studentId.

One of the other things I'd like to point is with a list I could do a

Collections.sort(List, Compatator), and choose any kind of comparator (e.g. sort by gpa, or studentId), with a TreeSet I'd have to instantiate a new object and re-populate it
appreciate all the replies.

12 years ago

Jeff Verdegan wrote:You want the entries to be unique? That screams Set. You want them sorted too? That screams TreeSet. I don't see why you're even considering a List.

But I realized a few issues with Sets if I wanted to do a comparison



Such as?



updating the TreeSet everytime one of the elements in the Set is changed is an issue. E.g. if you have a TreeSet with object E sorted by a double value in the object. When you add different elements of type E in the set, they will be sorted. However, when you change any of those elements the TreeSet will not update the order, which introduces complexities. One way I think this could be done is every time I do an update, copy the entire set into another using an iterator then point the reference to the new TreeSet, but that also sounds complicated.

12 years ago
I writing a module that requires a unique data structure, but I'm debating whether I should use a TreeSet or an ArrayList. Currently, performance isn't really an issue, since the list carries less than 500 elements.
Naturally, I should go for a Set since it contains unique elements. But I realized a few issues with Sets if I wanted to do a comparison.

E.g. With an ArrayList I can simply implement a new comparator and one I desire a sort I simply do a anytime I update a list. On the other hand, doing this after updating any values in a set seems to be a complicated task, since TreeSet will not automatically update the sorting structure after I update a value in the set.

Also, I can prevent duplicates in the ArrayList by simply checking if the object is contained in the list and by overriding the equals of T.

Wonder if anyone had any opinion about this? I'm inclined more to go with lists at this stage.


12 years ago
Thank you all for your replies. Metthew's reply was the prime reason for the post. I was suspicious I was breaking an object-oriented policy and it turns out I'm violating the entire equals() contract, which I forgot about.

Mike: Basically, I have got lists that contain Short values and a List that contains a String. Both refer to the object I am trying to search for. So let's call this object ObjectToSearch and it has 2 attributes one is a Short the other is a String.

I might at times, want to iterate on one of the lists with Short values and retrieve ObjectToSearch other times I want to do it using a String. This is just the equivalent of a database query with different fields.

And currently I am using HashMaps but it is getting absurd. I have a HashMap <Short,String> and then another HashMap<String,Short> then I have a third HashMap<String,Double> and a HashMap<String,Long> all for attributes that my guess is they can belong to one object.

I think I need to dig deeper here, but I for now I will rule out overriding equals() or hashCode()



12 years ago
I was thinking of writing an equals method in java, where I enable it to basically equal based on a string or a short. I'm thinking this may be handy if i have a List and I want to retrieve the object by either a String value or Short value.

One example would be:




I just want to know if there is anything bad I'm missing that would preclude me from writing such code. My other alternative would be to iterate over the ArrayList of type object X that contains the overridden method and manually compare. But that might be a slightly tedious task.


12 years ago
thanks for the response guys,

the thing is I have a 2 dimenstional array that consists of fractions between 0 and 1. What's worse is that i'm multiplying those numbers together. Sometimes hundreds of times. So I may het a numbe that is 1.44e-60, which double just can't take care of. So it's not just the rounding thing. I guess a double can hold values as low as 2-1074, but I'm deeply skeptical since I need to multiply, divide and add a lot.

It really looks like something I can handle in double....I guess I'll write a few programs to test it out.

14 years ago
There seems to be a rumor, that BigDecimal causes a performance hit when used. Of course, this is something I'll be worried about if I have to develop on Android.

Is there any truth to this? How bad are we talking here?
14 years ago
Hi,

Don't know if anyone ever considered this, but is implementing recusion on android ever a good idea? I know recursion is something that should be avoided whenever possible, but the algorithm I'd like to implement will be a lot easier with recursion.

I was just worried about the stack in general.


14 years ago
Ever since oracle purchased sun, and they have included their logo everywhere....its getting a bit discomforting to find out that some great open source projects (virtualbox, openoffice, netbeans..etc) have that red "o" on them now, I personally don't like that company, I've interacted with it for a while and developed applications using their database and it wasn't one of the great experiences. Now I login into what used to be sun's forums i see the theme changed to red and grey.

I know they own all of the products now, but is it really necessary to be explicit about it?

How did the regulatory bodies approve their purchase even though they know that mysql is going to be owned by it (I keep comparing it to the idea of Microsoft acquiring Canonical --truly and abhorrent idea)

Now less than two months ago, James Gosling left the company, he never stated the reason, but to me it seemed fairly obvious that he couldn't stay there while Oracle were calling the shots.


I'm just ranting here, but I guess that's why it's a meaningless drivel!

14 years ago
when you're overriding a method what is the constraint on the sope?on the type? you can't have it public in the superClass and private in the subclass, for example, also the return type should either be of the same type of a subclass of the return type

imagine in polymorphism what'll happen if you say



if the method say was private within child you should be getting a run-time error, so the compiler won't allow it in the first place because it destroys polymoprphism

your question really doesn't require an explanation, it's just a yes or no answer, this is a fundamental part of variable declaration so it's good to know the answer

think it's related to IIS and windows 2003 more than anything else

but manually is the best way

http://kb2.adobe.com/cps/195/tn_19575.html#iis6
15 years ago