lib-re / dublin-core-text-parser

Cataloguing tool for converting specially formatted text files containing dublin core metadata into various formats
MIT License
6 stars 0 forks source link

Refactor Element creation (factory and helper) #27

Open atla5 opened 8 years ago

atla5 commented 8 years ago

all Element subclasses currently contain nearly identical factor functions...

public static [Element] create[Element](String qualifierText, String value) { 
  ...
}

and different implementations of the same helper

public static String determineQualifier(String str){
  if(...){ return ...; }
  else if(...){ return ...; }
  else{ return ""; }
}

I had originally planned to put both of these into the Element superclass, make the former generic and inherited, and stub out the latter as an abstract function. I can't do this because they're static, but they need to be in order to be used to create the objects.

Finding no direct solution to this problem, having a bit of a time sensitivity, and given that it's not a functional issue at this point (code base is small, it's easy to infer, and unlikely to need revision), it stands as an ugly part of a codebase I'm otherwise pretty proud of.

I'd love some help with a solution to this while I work on other things, else I'll just come back to it.