Fun Stuff > CLIKC

A programming thread!

<< < (30/37) > >>

ankhtahr:
Any tips for easy parsing of commandline arguments? I could of course use more regexes, but that feels like a little bit of overkill. I'm free to use java.util, but not much more. Switch cases seem impractical because the arguments can occur in any order, but not multiple times.

Loki:
Never done that, but my approach would be: stuff all of them into an array, do linear search on the array (you only have a set universe of arguments, right?)

For determining the pairs of arguments and values, I'd indeed use regexes - or, more naively, indexOf(' ') plus substring.

ankhtahr:
Yeah, I've decided to just use regexes anyway. I think with this task I learnt a lot about those. Anyway, I now have around 11.5 hours until I have to hand this task in. This might be a long night.

And now I discovered that I can apply another design pattern to this task. Good thing I studied for the software engineering exam. I'm now using the Composite and the Stategy pattern.

ankhtahr:
AAAAAAARGH

uhm, anyone know a good way to divide a search string based on the following format into nice parts?

A search string consists of the command "search ", followed by either a single word, or multiple words put together using "AND(word1, word2)" or "OR(word1, word2)". You can nest ANDs and ORs. I wanted to model this using the composite design pattern, so I have "AndTerm", "OrTerm" and "FinalTerm", all extending "Term", with AndTerm and OrTerm consisting of two terms. Somehow I have to break a string down into a format I can use for these classes.

Edit:
Hmm, maybe I chose the wrong way to model this… This is difficult. I need to look into this.

ankhtahr:
ok, I realised that my modelling is pretty much shit, and I'm starting to panic. I have 7 hours left to make this a running, Checkstyle compliant solution.

It would go into too much detail if I'd explain everything here, but here's the task.

I'm currently implementing the search for single search terms. I'm now at a point where I can get an ArrayList of Sites in which the term occurs, and I can get a ranking for each. Basically for the single term search to work I just need to put the results in a structure together with the rankings and sort it by the rankings. My mind is too full of fuck to manage that currently. I'm trying to do it anyway though.

And then I have no idea what to do about the multiple search term things.

Edit: okay, I think I'm writing a class for the results, which implements comparable to sort the results by the ranking. Still no idea about the multiple search terms.
Edit2: Slightly less panicky now that I at least have the search for single terms working in theory. I still need to write the parser for the commandline interface for that, but that shouldn't be so difficult. Now I need to understand how the hell the ranking with multiple search terms is supposed to work.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version