I have implemented a factory in my project and it was recently suggested that I use attributes on my classes so the factory can determine which class to instantiate and pass back. I am new to the world of development and trying to rigidly follow the loosely-coupled rule, I wondering if relying on "hooks" (being the attributes) goes against this?
I don't think that using attributes would be increasing the coupling between the factory and the class it creates, in fact, it would decrease the coupling here because the factory would be discovering the information at runtime via the attributes. If anything you're simply trading the coupling between the class being created for the coupling to the attribute. That said, I'm not sure exactly what that buys you. The point of the factory is that you localize the creational logic in a single place. By putting it into attributes you've spread it all over your code again, partially defeating the purpose of the factory: now you have to look at both the factory and the attribute to understand how the object is being created.
Of course, I may be misunderstanding your question. You may mean that a class uses attributes on it's properties to indicate which of the properties need to be instantiated by the factory. In this case, you're replacing some configuration-driven mechanism for doing dependency injection. I can certainly see where that might be useful; having the factory discover an object's dependencies and automatically create them as well at runtime. In this case, you'd be slightly increasing the overall coupling of your code, since there is now a dependency between the attribute and the factory that didn't exist before. Overall, though you might decrease code complexity since you'd be able to do without specific code for each class to supply its particular dependencies or discover them from a configuration file.
If you're asking if using attributes a good idea, I think we probably need more information, but since you seem to be asking only if you're going to violate an OO principle, I don't think so. I don't see it increasing the coupling between the factory and the class being created and only slightly increasing the overall coupling of the code. Factories, by their nature, need more coupling than other classes anyway. Remember, it's loosely-coupled, not uncoupled. Uncoupled code doesn't do anything. You need relationships between classes to make anything happen.