Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 332429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:51:58+00:00 2026-05-12T09:51:58+00:00

In our CORE library we offer this class as a 20,000 line abstraction. Can

  • 0

In our CORE library we offer this class as a 20,000 line abstraction.
Can you see anything wrong with the way this is designed?

Note1: This class has a SharpZipLib backing.

Note2: SharpZipLib is approximately 20K lines.

public static class Compression
{
    public static Byte[] CompressBytes(Byte[] input);
    public static Byte[] CompressBytes(Byte[] input, Format format);
    public static Byte[] CompressBytes(Byte[] input, Format format, Level level);

    public static Byte[] DecompressBytes(Byte[] input);
    public static Byte[] DecompressBytes(Byte[] input, Format format);

    public static String CompressString(String input);
    public static String CompressString(String input, Format format);
    public static String CompressString(String input, Format format, Level level);

    public static String DecompressString(String input);
    public static String DecompressString(String input, Format format);

    public static void CompressFile(String input_file_path, String output_file_path);
    public static void CompressFile(String input_file_path, String output_file_path, Format format);
    public static void CompressFile(String input_file_path, String output_file_path, Format format, Level level);

    public static void DecompressFile(String input_file_path, String output_file_path);
    public static void DecompressFile(String input_file_path, String output_file_path, Format format);

    public static void CompressFolder(String input_folder_path, String output_file_path);
    public static void CompressFolder(String input_folder_path, String output_file_path, Format format);
    public static void CompressFolder(String input_folder_path, String output_file_path, Format format, Level level);

    public static void DecompressFolder(String input_file_path, String output_file_path);
    public static void DecompressFolder(String input_file_path, String output_file_path, Format format);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:51:58+00:00Added an answer on May 12, 2026 at 9:51 am

    I would recommend breaking this single class into several classes. Generally speaking, static utility classes break a lot of rules, not the least of which is Separation of Concerns. While yes, all of the methods in this class deal with compression, they are concerned with compressing different things. Some compress byte arrays, some compress strings, some compress files. I would break this single utility into multiple utilities:

    public static class ByteCompression
    {
        public static Byte[] Compress(Byte[] input);
        public static Byte[] Compress(Byte[] input, Format format);
        public static Byte[] Compress(Byte[] input, Format format, Level level);
    
        public static Byte[] Decompress(Byte[] input);
        public static Byte[] Decompress(Byte[] input, Format format);
    }
    
    public static class StringCompression
    
        public static String Compress(String input);
        public static String Compress(String input, Format format);
        public static String Compress(String input, Format format, Level level);
    
        public static String Decompress(String input);
        public static String Decompress(String input, Format format);
    }
    
    public static class FileCompression
    {
        public static void Compress(String input_file_path, String output_file_path);
        public static void Compress(String input_file_path, String output_file_path, Format format);
        public static void Compress(String input_file_path, String output_file_path, Format format, Level level);
    
        public static void Decompress(String input_file_path, String output_file_path);
        public static void Decompress(String input_file_path, String output_file_path, Format format);
    }
    
    public static FolderCompression
    {
        public static void Compress(String input_folder_path, String output_file_path);
        public static void Compress(String input_folder_path, String output_file_path, Format format);
        public static void Compress(String input_folder_path, String output_file_path, Format format, Level level);
    
        public static void Decompress(String input_file_path, String output_file_path);
        public static void Decompress(String input_file_path, String output_file_path, Format format);
    }
    

    The above utility classes reduce repetition, better encapsulate purpose, are more cohesive with their member methods, and are clearer in intent. You do have four static utility types rather than one, but you aren’t breaking as many rules/best practices this way. Try to avoid monolithic, do-everything utility classes. If you can, find a way to make them instance classes rather than static classes, especially if there is any shared data at the class level that is used across each compress/decompress method. That will improve thread safety.

    EDIT:

    A more ideal implementation would use extension methods, as andy commented. The File and Folder compression are a bit more difficult to implement as extensions, but I’ve tried my hand. The following examples better achieve what I was aiming for: separation of noun (or subject) from verb (or operation), providing a cleaner API that ultimately has less repetition, maintains separation of concerns, and is properly encapsulated.

    public static class ByteCompressionExtensions
    {
        public static byte[] Compress(this byte[] input);
        public static byte[] Compress(this byte[] input, Format format);
        public static byte[] Compress(this byte[] input, Format format, Level level);
    
        public static byte[] Decompress(this byte[] input);
        public static byte[] Decompress(this byte[] input, Format format);
    }
    
    // In use:
    byte[] myArray = new byte[] { ... };
    byte[] compArray = myArray.Compress();
    // Subject (noun) -----^      ^----- Operation (verb)
    
    
    public static class StringCompressionExtensions
    {
        public static byte[] Compress(this string input);
        public static byte[] Compress(this string input, Format format);
        public static byte[] Compress(this string input, Format format, Level level);
    
        // Extension method fail!! :( :( This conflicts with Decompress from the class above!
        public static string Decompress(this byte[] input);
        public static string Decompress(this byte[] input, Format format);
    }
    
    // In use:
    string myStr = "A string!";
    byte[] compArray = myStr.Compress();
    // Subject (noun) ---^      ^----- Operation (verb)
    myStr = compArray.Decompress(); // Fail! :(
    
    
    public static class FileCompressionExtensions
    {
        public static void Compress(this FileInfo input, FileInfo output);
        public static void Compress(this FileInfo input, FileInfo output, Format format);
        public static void Compress(this FileInfo input, FileInfo output, Format format, Level level);
    
        public static void Decompress(this FileInfo input, FileInfo output);
        public static void Decompress(this FileInfo input, FileInfo output, Format format);
    }
    
    // In use:
    FileInfo myFile = new FileInfo(input_file_path);
    FileInfo myCompFile = new FileInfo(output_file_path);
                     myFile.Compress(myCompFile);
    // Subject (noun) --^      ^----- Operation (verb)
                     myCompFile.Decompress(myFile);
    
    
    public static class FolderCompressionExtensions
    {
        public static void Compress(this DirectoryInfo input, DirectoryInfo output);
        public static void Compress(this DirectoryInfo input, DirectoryInfo output, Format format);
        public static void Compress(this DirectoryInfo input, DirectoryInfo output, Format format, Level level);
    
        public static void Decompress(this DirectoryInfo input, DirectoryInfo output);
        public static void Decompress(this DirectoryInfo input, DirectoryInfo output, Format format);
    }
    
    // In use:
    DirectoryInfo myDir = new DirectoryInfo(input_folder_path);
    DirectoryInfo myCompDir = new DirectoryInfo(output_folder_path);
                     myDir.Compress(myCompDir);
    // Subject (noun) --^      ^----- Operation (verb)
                     myCompDir.Decompress(myDir);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The company where I work created this application which is core to our business
Our core domain so far has an abstraction called PersonName with methods for firstName,
Linux binaries are usually dynamically linked to the core system library (libc). This keeps
We have a 12-year-old Ms Access app that we use for our core inventory
We're investigating the cloud for a couple of solutions and for our core product.
Our current automated build consists of 1 master box and 4 core-2-duo pizza boxed
At our company one of the core C++ classes (Database connection pointer) is implemented
In our app under development we are using Core Data with a sqlite backing
We are trying to port our code from HPX to AIX but getting core
We recently had one of our JVM's crash, leaving behind a core dump file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.