Ark: some help on software design please…?

The last few days I’ve been a little stuck on the Ark coding due to design decisions, but eventually figured a blog post to the community would get the right answers right away. (What I’m currently focusing on building is building a batch extract interface for ark, accessible through command line arguments and only shows the user the progress in a simple progress dialog, exiting when finished.)

Ark is divided into several parts:

  • part – the kpart along with the interface
  • app – the (relatively) trivial application that houses the kpart
  • kerfuffle – the extraction library base
  • plugins – the library plugins

The problems showed up when I tried to let the main app also take some arguments to instead of opening the file in a part, opening the part hidden and extracting the files one by one through it. It works fine with a single file, but once I want to do it sequentually I need some kind of a signal to do it sequentually. I went back and forth between several seemingly possible solutions, and eventually questioned how proper it actually is to use the kpart in this fashion (eg. using it almost like a library, and not showing the widget to the user). My motivation was to reuse the archive handling code already in ark’s kpart code, but if this reuse again introduces lots of ugly workarounds to actually make it work I’m not so sure anymore.

So here’s the solutions I currently see possible, I’d like some feedback on which one is the “KDE way”:

1. Ignore the need for a “finished” signal, and instead use an isBusy() function with a QTimer.  Extraction is still done through the KPart
My initial approach, aiming towards shaking as little as much of the existing ark codebase.

2. Start with a new “batch” subfolder, an command application that does not use the KPart, but instead kerfuffle extract library and its plugins.
Would need a lot of reorganising, but could also be a way of further single out the actual extracting code from the kpart into externally available classes. Could end up with some code duplication and/or reimplementation, for example with regards to error handling during extraction. Could also to a light degree split coding efforts between the batch interface and main application.

3. Abstract the extraction into yet another class, and recode the KPart to use this instead (maybe even treating the single extraction as a special case of a batch extract).
The batch operation will be then handled in the same application as the one housing the kpart. Would also probably be the source of new bugs, but fixing them would stabilize extraction/error handling in both the kpart and the batch extract interface. What kind of stops me with this one is I’m unsure if what I’m doing here is overabstracting the already abstract kerfuffle interface, or if it can be seen as adding another layer for simplifying the lowlevel kerfuffle library.

4. Is there a better way out of this chaos?
Maybe just give up? Do people really want the batch extract interface?

To summarize it, am I trying to use KParts in a way seen as incorrect? How much abstraction/ripping the code apart is just right? I kind of keep scaring myself with thoughts of future problems with bad decisions leading to tons of bugs and responsibilites i can’t handle..

EDIT: The kerfuffle archive was actually much easier to handle than I thought before writing this post. I’ve reorganized a few files now and found a quite elegant solution (variant of #2), avoiding code duplication by moving some parts of the KPart into the kerfuffle library. Thanks for the comments received.


12 Responses to “Ark: some help on software design please…?”

  1. Robin Says:

    I’d say number 3 sounds the best, maybe put the extracted code into kerfuffle (don’t know if feasible). Number 1 is a hack, the code in the KPart/UI should be as small as possible.

  2. Andre Says:

    I don’t think it’s overly necessary to have the batch mode, there are other things that might be more important. for example here i can’t add directories, it says it’s unsupported. But if you choose to realize it I’d also go for 3, adding the facility of an archive queue to the main application. I’d leave single mode in, not only as a special case, because display/progress report might be handled differently.

  3. elveo Says:

    whatever you do, dont give up. there s plenty of room for improvement in ark, and we re all glad that you picked it up and give it some love, thank you.

  4. Kyran Says:

    Not that I’m a specialist in KDE coding style, but wouldn’t it be the cleanest way to extend the functionality in the kerfuffle library: add a batch extract function and reimplement the current extract functionality as a special case using the kerfuffle internal batch extract function.
    Adding another abstraction layer in this case feels a bit overkill. To me it feels like all that functionality should go into the low level library.

    I have no idea how feasible all that is though (and I have no experience coding for KDE, so you should take my opinion with a grain of salt)

  5. Andreas Says:

    I’d say first do what the users need most (see Andre’s post and no, we are not the same person 🙂 ) and then, if and when you have the time, 3.

  6. shiny Says:

    Thanks for working on Ark! Don’t have a clue about you problem, but as already said before, don’t give up!

  7. Harald Says:

    @shiny: hee hee, thanks your support. glad you’re honest 🙂

    @kyran: Interesting, I’ll have a look at that in the morning, that might actually be a good way to solve this.

  8. Johannes Niess Says:

    The only difference against existing command line applications would be the progress dialog.

    Script writers won’t switch away from well established tools like gzip, tar etc. Even if they need ark for exotic use cases, they’d wrap the current ark version into a for loop shell script.

    GUI users don’t want a command line. All they need is selecting a couple of files for archive creation. Of course that is implemented since ages.

    I don’t see any users left. Thank you very much for making ark my favourite GUI compression tool.

  9. Andrea Says:

    “Thanks for working on Ark! Don’t have a clue about you problem, but as already said before, don’t give up!”

  10. Ryan Says:

    This isn’t a direct answer to your question, but it’s something to consider. Whatever you decide, I’m not sure that single extraction makes sense as a special case of batch extraction. In single extraction, you might want to just extract all files into a specific folder, but in batch extraction, each archive would need its own *sub*-folder. So basically, there is an action that is relevant to single extraction that is not relevant to batch extraction.

  11. k Says:

    hi I’m not a programmer, but I wanted to ask if Ark will have “extract here” in right-click-menu, which I use most of the time in kde3

  12. Harald Says:

    @k: Yes, that’s exactly one of the features I’m working on now.

Comments are closed.

%d bloggers like this: