Create Offline Demo Environment Database Substitute [closed]

I would like to know if there is a best practice for creating demo environments that substitutes database interaction into other forms of resource

i.e. creating .json files containing the data that was supposedly returned from a webservice call.

I wanted to know if there is already a standard way of obtaining the same result.

Thanks

1

Databases are easy to set up, and all of the major databases are either free or have a free version available. Therefore I would use an actual database in the demo environment. Advantages:

  • Complete consistency with production environment (or at least very close).
  • No need to write special handling for the different interface.
  • Easy to generate sample data (some tables could be taken directly from production. If there is sensitive data in your production database, you could write a simple routine to anonymise it–replace with fake names and addresses, for example.)

If the size of your demo environment is not a big deal, I would even access the database via a local web server if that helps the environment stay similar to production. There are prebuilt packages (such as XAMPP, which includes Apache, MySQL, and other tools) that make this sort of thing easy. Setting up some extra programs is easy, while making changes to your original program is hard. Therefore, minimize the latter whenever possible.

If duplicating a production-like environment is too heavyweight for your demo purposes, you could use a lightweight database (such as SQLite), and still have an interface that is fairly similar.

2

I wanted to know if there is already a standard way of obtaining the same result.

The standard for seperating businesslogic from databaseaccess is to use the repository pattern .

Your app can have

  • one implementation to access the real data for production and
  • a 2nd implementation that reads the data from demo implementation and ignores the saveToDatabase calls.

1

I’m unsure what do you want to do here. Create a showcase of your application (1)? Test it in staging/development environment (2)? Unit test it (3)?

  1. If you want to have a demo version of your application (for example in order to show to a potential customer what she gets, without actually letting the person to have an access to all the features and without polluting the production database), just duplicate the database. In most cases, the simple 1 to 1 duplication will work; if not, you may enhance the demo database with security restrictions which would make it impossible to change what should be changed only in production (for example the password of the demo user).

  2. If your goal is to have a staging environment, the same technique of database duplication would be used. Here, you don’t change anything: you have to have an exact duplicate of the database schema. The development environment will be based on a copy of a database too, given that there, the database may contain developer-specific changes.

  3. Finally, if you’re asking about unit testing, then mocking is generally used to make it easy to test the classes in a database-agnostic and data-agnostic way. Here, effectively, the database (and the data access layer in general) would be substituted with a mock which will provide specific answers to specific requests, like:

    class SampleCustomerMock
    {
        Customer FindCustomerById(int id)
        {
            // Just return a sample customer, without taking in account the `id`.
            return new Customer("John", "Miller", 36, Gender.Male);
        }
    }
    
    class MissingCustomerMock
    {
        Customer FindCustomerById(int id)
        {
            throw new RecordNotFound();
        }
    }
    

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật