In my project, I have a header class that represents a globally unique key for a piece of information within the system, for example, to whom it belongs, what time it exists, etc. Inside the same class of headers, I also have fields for information specific to this data instance, for example, who created this version of the information, when it was created, if its new data should be stored in a database, etc.
The following is an example of storing some information in a data transport class and requesting it back.
var header = new IntvlDataHeader( datapoint: Guid.NewGuid(), element: Guid.NewGuid(), intervalUtc: DateTime.Now.Date); package.StockData_Decimal(header, 5m); decimal cloneData; package.TryGetData_Decimal(ref header, out cloneData);
Notice how I did TryGetData_Decimal passed the header variable by reference. IntvlDataHeader is a class, and if the data is inside TryGetData, the link is replaced with a new instance of IntvlDataHeader, which has specific information about the instance in addition to the same unique key information.
Does the key combine with the specific data of a specific instance and use the ref parameter both in poor design and outside it? Will there be an attempt to split another class so that there are two parameters and ref parameters would be better or avoid any potential problems?
public bool TryGetData_Decimal(ref IntvlDataHeader header, out decimal data) method signature public bool TryGetData_Decimal(ref IntvlDataHeader header, out decimal data)
source share