liberty-eiffel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cached queries


From: Paolo Redaelli
Subject: Cached queries
Date: Sun, 7 Jan 2024 23:41:42 +0100
User-agent: Mozilla Thunderbird

I found myself using this pattern over and over again:

class FOO

feature {ANY}

    costly_query: SOMETHING is

        do

            if cached_costly_query=Void then compute_costly_query end

            Result := cached_costly_query

        end

feature {} -- Implementation

    cached_costly_query: like costly_query

    compute_costly_query is

        do

            -- ......

        ensure cached_costly_query/=Void

        end

end


Do you know of a more "precanned" / more elegant / better way of doing it?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]