• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: BOOL takeStupidRoad = NO (search app design question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BOOL takeStupidRoad = NO (search app design question)


  • Subject: Re: BOOL takeStupidRoad = NO (search app design question)
  • From: Izidor Jerebic <email@hidden>
  • Date: Mon, 23 Mar 2009 11:08:45 +0100

Hello, David,

there is nothing wrong with your aproach. For this amount of data and for its first version the program should be ok.

However, if you find out later that your search needs to be faster/ consume less memory/work with more files, you will need to optimize the application.

Note that this is the correct approach. First make the application work. Optimize later, when/if necessary.

If you structure your application well (ObjectOriented design), then you will be able to switch new search code and snippet generation into application without changing the rest of application. This is the main and most important design issue - how to structure your application so you can improve it with as little work as possible.

Search optimization can take many forms, from using SearchKit or some other search library to build your private index, or using Spotlight API, or some other search tool (such as programmatically running the command like 'grep' and parsing its output). The software will become more complicated, because the generation of snippets may or may not be supported by the search code you will use, so you may need to generate them yourself, separately from search.


izidor


On 21.3.2009, at 11:24, David Yamartino wrote:

Hi All,

I have a general design question. I'm going through the latest Hillegass and
Kochan programming books for the purpose of writing a simple search app. I
think I've figured out a way to do this, but having no experience in
programming, I have no idea if my approach is good or bad. I'd rather not
take the stupid road if I can avoid it, so I'm hoping someone may be able to
set me straight before I go too far down the road.


So if you're inclined to take a few minutes to consider what I've written
below, I'd appreciate it.


In any case, good luck with your projects,

David

--------------------------------------------------------------------------------------------

*APPLICATION DESCRIPTION:*
I have a library of about 1,500 text files, about 93 MB total.

The application window opens with two views: left view shows the hierarchy
of folders/files, and when you click on a file, the text of the file appears
in the right view, where you can read, scroll, etc.


The user inputs a term into the search field, and when the search is
executed, the folders/files on the left view disappear and the view is
repopulated with a new hierarchy showing only the folders/files where the
search term appears. Below each file will be snippets of where the term
appears within the text. Click on a snippet and the right view will show the
entire text of the file zoomed to where the snippet appears.


For example, if the search term is "child education":

*Book X*
The *child education* conference focused on two age groups: 5-7 years,
and 8-10 years.
. . . because the *child* wasn't receiving the needed attention in
her *education*, her parents decided . . .
. . . and over the years the *child education* policy was broadened
to include moral education and . . .



*MY APPROACH*:
I can load the text of the 1,500 files into 1500 NSStrings with something
like


stringWithContentsOfFile


Then I can search the 1,500 NSStrings to locate the position of the search
term within each string, then extract a range (including some words before
and some words after) to make the snippets. Using



rangeOfString

NSMakeRange

etc.



*QUESTION:*

Would this be a workable approach? Or is it a really stupid idea to have to
load 93 MB of files into 1,500 NSStrings every time the program starts up?
If not this approach, what would be more efficient?



Thanks. _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: BOOL takeStupidRoad = NO (search app design question)
      • From: David Yamartino <email@hidden>
References: 
 >BOOL takeStupidRoad = NO (search app design question) (From: David Yamartino <email@hidden>)

  • Prev by Date: Could really use the help of a custom view expert
  • Next by Date: Re: BOOL takeStupidRoad = NO (search app design question)
  • Previous by thread: BOOL takeStupidRoad = NO (search app design question)
  • Next by thread: Re: BOOL takeStupidRoad = NO (search app design question)
  • Index(es):
    • Date
    • Thread