This project has moved and is read-only. For the latest updates, please go here.

Sealed classes

Sep 23, 2014 at 9:32 AM
Are there any serious reason why StyleTransformer, CssTransformer, ScriptTransformer, etc. classes are sealed?
Sep 23, 2014 at 9:35 AM
These classes do not require extension and this increases performance.
Sep 23, 2014 at 10:41 AM
But these classes are not performance critical. Not only that, but sealing classes only increases chances of negligibly increasing performance and should only be used as last resort in that case.
While they do not /require/ extension, that does not mean that there is no case when it is convenient to do so.

IMHO limiting code extensibility by making micro optimizations is bad architectural decision. After all "The First Rule of Program Optimization: Don't do it".
Sep 23, 2014 at 10:51 AM
These classes will remain sealed.

There and without it many classes and interfaces for extension: ITransformer and TransformerBase, ITranslator and TranslatorWithNativeMinificationBase, IPostProcessor and PostProcessorBase, and IMinifier.
Sep 23, 2014 at 11:18 AM
Well that definitely makes it harder to work around bugs.
Whatever. At least accept my pull request where I prevent throwing exceptions when bundle does not have any resources.
I hope release cycle is not too long...
Sep 23, 2014 at 11:28 AM
Why do need an empty bundle?
Sep 23, 2014 at 11:46 AM
Think first whether you need the Bundle Transformer infrastructure? May be your problem is solved at the level of System.Web.Optimization and you just need to implement the IBundleTransform interface.
Sep 23, 2014 at 12:39 PM
Edited Sep 23, 2014 at 12:40 PM
Why do need an empty bundle?
I assemble bundles from folders based on controller and action. Sometimes folders are empty, therefore empty bundles are formed.
I could check if bundle is not empty before calling Scripts.Render(), but Bundle.EnumerateFiles() is bothersome to call, not to mention performance penalty since it always creates a new list.
From logical point of view rendering empty bundle should return empty result instead of throwing exceptions. The is nothing wrong to have an empty bundle.
IBundleTransform was my first choice, but it doesn't really work well with Handlebars in debug mode. Implementing IPostProcessor was not as complicated.
Sep 23, 2014 at 12:46 PM
ОК. In the coming days I will publish a new release with this pull request.
Sep 23, 2014 at 1:20 PM
Ok, thanks.
Sep 23, 2014 at 7:15 PM
In Bundle Transformer 1.9.22 solved the problem with empty bundles.