如何用C语言制作这样的程序,我可以在将来随时升级它? [英] How can I make such a program in C language in which I can upgrade it whenever I want it in future ?

查看:84
本文介绍了如何用C语言制作这样的程序,我可以在将来随时升级它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如

i希望制作一个处理餐厅结算的程序。

但是如果我将来需要一些升级,比如增加费率,税金等





我的尝试:



i没有尝试,我很困惑该怎么办

for example
i want to make a program that handles restaurant billing.
but if i will need some upgradation in future like increase in rates,tax etc


What I have tried:

i didnt tried, i m getting confused what to do

推荐答案

简单:存储可能发生变化的费率一个人类可读形式的外部文件,以便在法规更改时可以轻松更改。

当您启动应用程序时,您会读取该文件并应用当前值。



你无法计划所有事情:所以计划可能的事情,并编写你的代码,以便在你忘记它的工作原理时很容易理解和修改它们!这真的是你能做的最好的事情。
Simple: store the rates that are liable to change in an external file in a human readable form so they can be changed easily when the regulations change.
When you app starts, you read the file, and apply the current values.

You can't plan for everything: so plan for what is likely, and write your code so it is easy to understand and modify next year when you have forgotten how it works! That really is about the best you can do.


你必须存储可能在某种配置存储中发生变化的数据。例如,这可能是一个具有特定格式的文件,在您的应用程序启动时会加载它。



可能的文件格式(以及其他)纯文本(需要编写解析器) ),XML(使用XML库)或二进制(例如存储C结构)。
You have to store the data that might change in some kind of configuration storage. That might be for example a file with a specific format that is loaded when your application starts.

Possible file formats are (among others) plain text (requires writing a parser), XML (using an XML library), or binary (e.g. storing C structures).


Quote:

但如果我将来需要一些升级,如费率,税收等的增加

but if i will need some upgradation in future like increase in rates,tax etc



这不是'升级',这是'配置'。

如果您打算出售餐厅结算系统,您需要提供一种方法来定制您的程序,餐馆之间的任何不同(表号,卡,......)或可能随时间变化(餐馆名称,电话,税率......)

这就是所谓的'config',你的程序必须在启动时加载配置。



什么不是随时间变化的是数学,账单布局,跟踪账单的数据库......


This is not 'upgrade', this is 'config'.
If you plan to sell a restaurant billing system, you need to provide a way to customize your program on anything that is different between restaurants (tables numbers, card, ...) or that can change over time (restaurant name, phone, tax rate ...)
This is what is named 'config', your program must load the config on launch.

What don't change over time is the maths, bill layout, the database that keep track of bills ...


这篇关于如何用C语言制作这样的程序,我可以在将来随时升级它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆